/*
  pm-app の見た目（v0.4 2026-10-15 鈴木「システム全体をフラットデザインに」を受けて全面改訂。v0.6 2026-10-20 余白・行間を広げ、プロジェクト管理をカード＋枠線のグループに）
  フラットデザインの約束：影・ぼかし・グラデーション・立体感を使わない。面は単色で塗り分け、縁取りは最小限、角はごく小さく
  配色：TERRACE（メイン #0a3d33 深緑は左のメニュー全面と主ボタン・サブ #ecc12b 黄は選択中の目印だけ）。--brand は組織ごとに画面側で差し替える
  文字：英数字は Inter、和文は Noto Sans JP。見出し・数字は太く、本文は400〜500で序列をつける
  押しやすさ：タッチ端末（pointer: coarse）では押せる範囲を44px以上に広げる
*/
:root {
  --brand: #0a3d33;
  --brand-fg: var(--brand);
  --brand-hover: color-mix(in srgb, var(--brand) 84%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 8%, #fff);
  --brand-soft-2: color-mix(in srgb, var(--brand) 15%, #fff);
  --brand-mid: color-mix(in srgb, var(--brand) 38%, #fff);
  --brand-line: color-mix(in srgb, var(--brand) 30%, #fff);
  --sub: #ecc12b;
  --gp: #a37a00;

  --bg: #ffffff;
  --bg-muted: #e6e9ee;
  --edge: #d6dbe2;        /* 白背景の上でブロックを囲う線 */
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --hover: #eef0f3;
  --line: #e4e7ec;
  --line-strong: #cbd1d9;
  --text: #15181d;
  --text-2: #3a4049;
  --muted: #646b76;
  --faint: #959ca8;

  --danger: #d33a2c;
  --danger-soft: #fbe9e7;
  --danger-line: #f3b9b3;
  --warn: #b25e00;
  --warn-soft: #fff1dc;
  --warn-line: #f5cf96;
  --ok: #157a4a;
  --ok-soft: #e1f5ea;
  --done: #959ca8;

  --on-brand: #ffffff;
  --on-brand-2: rgba(255, 255, 255, .78);
  --on-brand-3: rgba(255, 255, 255, .56);
  --on-brand-fill: rgba(255, 255, 255, .12);
  --on-brand-fill-2: rgba(255, 255, 255, .2);
  --scrim: rgba(21, 24, 29, .42);

  --r-sm: 3px;
  --r: 4px;
  --r-lg: 6px;
  --header-h: 56px;
  --nav-h: 60px;
  --side-w: 248px;
  --ctl-h: 36px;
  --font: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  color-scheme: light;
}
@media (pointer: coarse) { :root { --ctl-h: 44px; } }
@media (prefers-color-scheme: dark) {
  :root {
    --brand-fg: color-mix(in srgb, var(--brand) 32%, #fff);
    --brand-soft: color-mix(in srgb, var(--brand) 26%, #131716);
    --brand-soft-2: color-mix(in srgb, var(--brand) 40%, #131716);
    --brand-mid: color-mix(in srgb, var(--brand) 60%, #e8ebe9);
    --brand-line: color-mix(in srgb, var(--brand) 62%, #131716);
    --gp: #e0b84a;
    --bg: #0e1110;
    --bg-muted: #222826;
    --edge: #313a39;
    --surface: #171b1a;
    --surface-2: #1d2220;
    --hover: #222826;
    --line: #283030;
    --line-strong: #3a4341;
    --text: #eceff0;
    --text-2: #c9cfcd;
    --muted: #959e9a;
    --faint: #6c7571;
    --danger: #f97066;
    --danger-soft: #2c1715;
    --danger-line: #6b2a24;
    --warn: #fdb022;
    --warn-soft: #2a2110;
    --warn-line: #5e4616;
    --ok: #47cd89;
    --ok-soft: #10261b;
    --done: #6c7571;
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ===== 動きの軽さ：長い一覧は画面に入るまで描画を後回し、動きを減らす設定の端末では動かさない ===== */
.list > .task, .entry { content-visibility: auto; contain-intrinsic-size: auto 56px; }
.bcard { content-visibility: auto; contain-intrinsic-size: auto 104px; }
.task-view:empty, .defer:empty { min-height: 50vh; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; } }

/* ===== 土台 ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.65; letter-spacing: .01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
@media (max-width: 640px) { body { font-size: 15px; } }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--brand-fg); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-fg); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: none; display: block; }
.icon.xs { width: 13px; height: 13px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.neg { color: var(--danger); }
.muted { color: var(--muted); }

/* ===== 枠（スマホ：上の帯＋下のメニュー ／ PC：左のサイドバー）。帯とサイドバーはメインカラーの一枚塗り ===== */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: calc(var(--header-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
  background: var(--brand); color: var(--on-brand);
}
.topbar :focus-visible, .sidenav :focus-visible { outline-color: #fff; }
.brand-link { display: flex; align-items: center; margin-right: auto; min-height: 40px; text-decoration: none; }
.brand-logo { display: block; height: 20px; width: auto; max-width: 168px; object-fit: contain; }
/* 既定のロゴ（深緑の文字）は白に反転。組織が入れたロゴは白い板の上に置く */
.topbar .brand-logo.default, .sidenav .brand-logo.default { filter: brightness(0) invert(1); }
.topbar .brand-logo:not(.default), .sidenav .brand-logo:not(.default) { height: 34px; padding: 6px 10px; background: #fff; border-radius: var(--r); }
.brand-name { font-weight: 700; color: var(--on-brand); font-size: 16px; letter-spacing: .02em; }

/* スマホの上の帯：右端に「タスクを追加」 */
.top-add { width: 36px; padding: 0; background: var(--on-brand-fill-2); color: var(--on-brand); }
.top-add:hover { background: var(--on-brand-fill-2); color: var(--on-brand); }
.top-add .icon { width: 18px; height: 18px; }

.sidenav { display: none; }
.main {
  min-width: 0; width: 100%; max-width: 1080px; margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.navlink { position: relative; text-decoration: none; color: var(--muted); }
.navlink .short { display: none; }
.bottomnav .navlink {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--nav-h); font-size: 11px; font-weight: 500; line-height: 1.2; letter-spacing: 0;
}
.bottomnav .navlink .icon { width: 22px; height: 22px; }
.bottomnav .navlink .long { display: none; }
.bottomnav .navlink .short { display: inline; }
.bottomnav .navlink.active { color: var(--brand-fg); font-weight: 700; }
.bottomnav .navlink.active::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; background: var(--sub); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .topbar, .bottomnav { display: none; }
  .sidenav {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    padding: 20px 12px 16px; background: var(--brand); color: var(--on-brand);
  }
  .side-brand { display: flex; align-items: center; height: 40px; padding: 0 10px; margin-bottom: 16px; }
  .side-brand .brand-logo { height: 22px; }
  .side-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--on-brand-3); padding: 0 10px; margin: 18px 0 6px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav .navlink {
    display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r);
    font-size: 14px; font-weight: 500; color: var(--on-brand-2);
  }
  .side-nav .navlink .icon { color: var(--on-brand-3); }
  .side-nav .navlink:hover { background: var(--on-brand-fill); color: var(--on-brand); }
  .side-nav .navlink:hover .icon { color: var(--on-brand); }
  .side-nav .navlink.active { background: var(--on-brand-fill-2); color: var(--on-brand); font-weight: 700; }
  .side-nav .navlink.active .icon { color: var(--sub); }
  .side-nav .navlink.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; background: var(--sub); }
  .side-nav .gap { height: 12px; }
  .side-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--on-brand-fill-2); display: grid; gap: 12px; }
  .side-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .side-user .avatar { width: 28px; height: 28px; font-size: 12px; background: #fff; color: var(--brand); }
  .side-user .who { min-width: 0; line-height: 1.35; }
  .side-user .name { font-size: 13px; font-weight: 700; color: var(--on-brand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-user .org { font-size: 12px; color: var(--on-brand-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 32px 40px 56px; max-width: 1160px; }
  .main.wide { max-width: none; }
}

/* ===== 見出し ===== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { font-size: 24px; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; margin: 0; }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--text); text-decoration: underline; }
.block-title { font-size: 15px; font-weight: 700; margin: 0; }

/* ===== ボタン・切り替え・入力欄（縁取りなし・単色の面） ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  height: var(--ctl-h); padding: 0 14px; border-radius: var(--r); cursor: pointer; text-decoration: none;
  font-size: 14px; font-weight: 600; line-height: 1;
  border: 0; background: var(--bg-muted); color: var(--text-2);
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--line-strong); color: var(--text); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
@media (pointer: coarse) { .btn.small { height: 40px; } }
.btn.square { width: var(--ctl-h); padding: 0; }
.btn.small.square { width: 30px; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: var(--danger-line); color: var(--danger); }
.btn[aria-busy="true"] { opacity: .65; cursor: progress; }
.link-btn { border: 0; background: none; padding: 0 2px; min-height: 32px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-fg); }
.link-btn:hover { text-decoration: underline; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--bg-muted); }
.seg button {
  height: calc(var(--ctl-h) - 6px); padding: 0 12px; border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }

.stepper { display: inline-flex; align-items: center; height: var(--ctl-h); border-radius: var(--r); background: var(--bg-muted); }
.stepper button { display: grid; place-items: center; width: 34px; height: 100%; border: 0; background: none; cursor: pointer; color: var(--muted); }
.stepper button:hover { color: var(--text); background: var(--line-strong); }
.stepper button:first-child { border-radius: var(--r) 0 0 var(--r); }
.stepper button:last-child { border-radius: 0 var(--r) var(--r) 0; }
.stepper .icon { width: 16px; height: 16px; }
.stepper .lbl { padding: 0 8px; font-size: 14px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.input {
  width: 100%; height: var(--ctl-h); padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: 14px; transition: border-color .12s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--muted); }
.input:focus { outline: 2px solid var(--brand-fg); outline-offset: -1px; border-color: var(--brand-fg); }
@media (max-width: 640px) { .input { font-size: 16px; } }
select.input {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23646b76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search .input { padding-left: 34px; }
.checkline { display: inline-flex; align-items: center; gap: 8px; height: var(--ctl-h); font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.checkline input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toolbar select.input { width: auto; min-width: 180px; max-width: 260px; }
.toolbar .spacer { margin-left: auto; }
.toolbar .count-note { font-size: 13px; color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) {
  .search { max-width: none; flex-basis: 100%; }
  .toolbar select.input { flex: 1 1 auto; max-width: none; }
}

/* ===== 絞り込み（パネルとチップ） ===== */
.btn .cnt { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-sm); background: var(--sub); color: #15181d; font-size: 11px; font-weight: 700; }
.btn.on { background: var(--brand-soft-2); color: var(--brand-fg); }
.btn.on:hover { background: var(--brand-line); }
.btn[aria-expanded="true"] .icon { color: var(--brand-fg); }
.filters { display: grid; gap: 10px; padding: 12px 16px; margin: -8px 0 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); }
.frow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.filters > .frow { min-width: 0; } /* 選択肢の文字幅に引っ張られて枠からはみ出さないように */
.frow .fk { flex: none; width: 48px; font-size: 12px; font-weight: 700; color: var(--muted); }
.frow .input { width: auto; min-width: 0; max-width: 280px; flex: 1 1 160px; }
.frow .spacer { margin-left: auto; }
@media (max-width: 640px) { .frow .input { max-width: none; } .frow .fk + .input { flex-basis: calc(100% - 56px); } }
.chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 0; border-radius: var(--r); cursor: pointer;
  background: var(--bg-muted); color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; transition: background .12s, color .12s;
}
.chip:hover { background: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--brand); color: #fff; }
@media (pointer: coarse) { .chip { height: 40px; padding: 0 14px; } }

/* ===== 小さな部品（状態ラベル・担当・取引先の色）。ラベルは単色の面、担当は単色の丸 ===== */
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; background: var(--bg-muted); color: var(--text-2);
}
.badge.s-todo { color: var(--muted); }
.badge.s-doing { background: var(--brand-soft-2); color: var(--brand-fg); }
.badge.s-hold { background: var(--warn-soft); color: var(--warn); }
.badge.s-done { background: var(--ok-soft); color: var(--ok); }
.badge.high { background: var(--danger-soft); color: var(--danger); }
.badge.k-sales { background: var(--brand-soft-2); color: var(--brand-fg); }
.badge.k-outsource { background: var(--warn-soft); color: var(--warn); }
.badge.k-purchase { background: var(--danger-soft); color: var(--danger); }
.badge.plan { background: var(--surface-2); color: var(--muted); }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--c, #646b76); color: #fff;
}
.person { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.cdot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--faint)); }

/* ===== 集計カード（白い面。数字の色で意味を分ける） ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 32px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .stats > :last-child:nth-child(odd) { grid-column: span 2; } }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; min-width: 0;
  padding: 18px 20px; border: 1px solid var(--edge); border-radius: var(--r-lg); background: var(--surface);
  cursor: pointer; color: inherit; transition: background .12s;
}
.stat:hover { background: var(--surface-2); }
.stat .k { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.stat .v { font-size: clamp(22px, 1.2vw + 14px, 30px); font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat.danger .v { color: var(--danger); }
.stat.warn .v { color: var(--warn); }
.stat.brand .v { color: var(--brand-fg); }
.stat.zero .v { color: var(--faint); }
.stat .s { font-size: 12px; color: var(--muted); line-height: 1.4; }
.stat.static { cursor: default; }
.stat.static:hover { background: var(--surface); }
@media (max-width: 760px) { .stat { padding: 12px 14px 14px; } .stat .v { font-size: 24px; } }
.delta { font-weight: 700; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }

/* ===== セクションとタスクの行 ===== */
.section { margin-bottom: 32px; scroll-margin-top: calc(var(--header-h) + 16px); }
.section-head {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 28px; margin: 0 0 10px; padding: 0 2px;
  border: 0; background: none; text-align: left; font-size: 15px; font-weight: 700; color: var(--text);
}
.section-head a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.section-head a:hover { text-decoration: underline; }
.section-head.toggle { cursor: pointer; min-height: 36px; }
.section-head .count { font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--bg-muted); border-radius: var(--r-sm); padding: 0 7px; line-height: 20px; font-variant-numeric: tabular-nums; }
.section-head.danger { color: var(--danger); }
.section-head.danger .count { background: var(--danger); color: #fff; }
.section-head.warn { color: var(--warn); }
.section-head.warn .count { background: var(--warn); color: #fff; }
.section-head .caret { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.section-head .caret .icon { transition: transform .15s; }
.section-head[aria-expanded="true"] .caret .icon { transform: rotate(90deg); }
.section-note { font-size: 13px; color: var(--muted); margin: -2px 2px 10px; }
.caption { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }

.list { background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-lg); overflow: hidden; }
.task { display: flex; align-items: flex-start; border-top: 1px solid var(--line); transition: background .1s; }
.task:first-child { border-top: 0; }
.task:hover { background: var(--surface-2); }
.task.child { padding-left: 28px; }
.check {
  flex: none; width: 44px; align-self: stretch; display: flex; align-items: flex-start; justify-content: center;
  padding: 16px 0 0; border: 0; background: none; cursor: pointer;
}
.check span {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); background: none;
  display: grid; place-items: center; color: transparent; transition: background .12s, border-color .12s, color .12s;
}
.check span svg { width: 11px; height: 11px; }
.check:hover span { border-color: var(--brand-fg); color: var(--brand-mid); }
.check[aria-checked="true"] span { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (pointer: coarse) { .check { width: 52px; padding-top: 15px; } .check span { width: 22px; height: 22px; } }
.task-body { flex: 1; min-width: 0; padding: 14px 18px 14px 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.task-title { font-size: 15px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 640px) { .task-title { font-size: 15.5px; } }
.task.done .task-title { color: var(--done); text-decoration: line-through; font-weight: 400; }
.parent-label { font-size: 12.5px; color: var(--faint); margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parent-label::before { content: "↳ "; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.meta .badge { height: 20px; font-size: 11.5px; }
/* 取引先・案件はタグ（文字全体を薄く塗る） */
.where { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 280px; height: 22px; padding: 0 8px 0 7px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--text-2); }
.where .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.due.over { color: var(--danger); font-weight: 600; }
.due.today { color: var(--warn); font-weight: 600; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; background: var(--surface); border: 1px dashed var(--edge); border-radius: var(--r-lg); }
.notice { font-size: 13px; color: var(--text-2); background: var(--brand-soft); border-left: 4px solid var(--brand-fg); border-radius: var(--r); padding: 10px 14px; margin-bottom: 20px; }
.notice.ng { background: var(--danger-soft); color: var(--danger); border-left-color: var(--danger); }

/* ===== タスク管理：表示の切り替え ===== */
.view-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.view-tabs::-webkit-scrollbar { display: none; }
.view-tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px;
  border: 0; background: none; cursor: pointer; white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--muted);
}
.view-tabs button .icon { width: 16px; height: 16px; }
.view-tabs button:hover { color: var(--text); }
.view-tabs button[aria-selected="true"] { color: var(--brand-fg); font-weight: 700; }
.view-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px; background: var(--brand-fg); }
@media (max-width: 560px) { .view-tabs { gap: 0; } .view-tabs .icon { display: none; } .view-tabs button { padding: 0 9px; } }

/* ===== 表 ===== */
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-lg); }
.table-wrap.tall { max-height: calc(100vh - 230px); min-height: 240px; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.grid th, table.grid td { height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
table.grid tbody tr:last-child > * { border-bottom: 0; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; height: 38px; background: var(--surface-2);
  font-size: 12px; font-weight: 700; color: var(--text-2); letter-spacing: .02em; border-bottom: 0;
}
table.grid thead th button { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0; border: 0; background: none; cursor: pointer; color: inherit; font-weight: inherit; }
table.grid thead th button:hover, table.grid thead th[aria-sort] { color: var(--brand-fg); }
table.grid thead th .icon { width: 12px; height: 12px; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid tbody tr { transition: background .1s; }
table.grid tbody tr:hover > * { background: var(--surface-2); }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tfoot th, table.grid tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.cell-link { display: block; max-width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; }
.cell-link:hover { color: var(--brand-fg); }
.cell-parent { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.cell-parent::before { content: "↳ "; }
.cell-sub { font-size: 12px; color: var(--muted); margin-left: 6px; }
.faint { color: var(--faint); }

/* 列幅を先に決める（table-layout: fixed）：行を足しても表全体を測り直さないので、長い表でも描画が軽い。タスク名の列が残りの幅を使う */
table.grid.tasks { table-layout: fixed; min-width: 1000px; }
table.grid.tasks th, table.grid.tasks td { overflow: hidden; text-overflow: ellipsis; }
table.grid.tasks .c-check { width: 44px; padding: 0 0 0 4px; }
table.grid.tasks .c-check .check { padding: 0; align-items: center; min-height: 48px; }
table.grid.tasks .c-title { white-space: normal; padding-top: 8px; padding-bottom: 8px; }
table.grid.tasks .c-title .cell-parent { white-space: nowrap; }
table.grid.tasks .c-title .cell-link { white-space: nowrap; }
table.grid.tasks .c-where { width: 230px; }
table.grid.tasks .c-status { width: 84px; }
table.grid.tasks .c-assignee { width: 104px; }
table.grid.tasks .c-start { width: 76px; }
table.grid.tasks .c-due { width: 150px; }
table.grid.tasks .c-priority { width: 72px; }
table.grid.tasks .c-where .where { max-width: 220px; }
table.grid.tasks .c-where .proj { color: var(--muted); }
table.grid.tasks .c-due.over { color: var(--danger); font-weight: 600; }
table.grid.tasks tr.done .cell-link { color: var(--done); text-decoration: line-through; font-weight: 400; }

/* ===== ガントチャート（横にスクロールして先の予定を見る）。帯は縁取りなしの単色 ===== */
.gantt-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.gantt-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-left: auto; font-size: 12px; color: var(--muted); }
.gantt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.gantt-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; background: var(--brand-soft-2); }
.gantt-legend i.s-doing { background: var(--brand); }
.gantt-legend i.over { background: var(--danger-soft); }
.gantt-legend i.s-hold { background: var(--warn-soft); }
.gantt-legend i.pbar { height: 4px; background: var(--brand-mid); }
.gantt-wrap {
  overflow: auto; max-height: calc(100vh - 250px); min-height: 320px; overscroll-behavior-x: contain;
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-lg);
}
.gantt { --gname: 260px; --dw: 28px; display: grid; grid-template-columns: var(--gname) repeat(var(--days), var(--dw)); width: max-content; }
@media (max-width: 640px) { .gantt { --gname: 132px; --dw: 26px; } }
.g-corner {
  position: sticky; top: 0; left: 0; z-index: 6; display: flex; align-items: flex-end; padding: 0 14px 10px;
  background: var(--surface-2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--text-2);
}
.g-month { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; height: 28px; background: var(--surface-2); border-left: 1px solid var(--line); }
.g-month span { position: sticky; left: calc(var(--gname) + 6px); padding: 0 8px; font-size: 12px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.g-day {
  position: sticky; top: 28px; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 40px; background: var(--surface-2); border-bottom: 1px solid var(--line); line-height: 1.2;
  font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.g-day .w { font-size: 10px; color: var(--faint); }
.g-day.weekend { color: var(--faint); }
.g-day.today .d { padding: 0 5px; border-radius: var(--r-sm); background: var(--brand); color: #fff; font-weight: 700; }
.g-col { z-index: 0; border-left: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.g-col.mon { border-left-color: var(--line); }
.g-col.weekend { background: color-mix(in srgb, var(--bg) 75%, transparent); }
.g-col.today { background: color-mix(in srgb, var(--danger) 5%, transparent); border-left: 2px solid color-mix(in srgb, var(--danger) 70%, transparent); }
.g-band { grid-column: 2 / -1; z-index: 0; background: var(--surface-2); border-top: 1px solid var(--line); }
.g-name {
  position: sticky; left: 0; z-index: 3; grid-column: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 0 14px; border: 0; border-right: 1px solid var(--line); background: var(--surface);
  font-size: 13px; text-align: left; color: var(--text);
}
.g-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-task { cursor: pointer; }
.g-task:hover { background: var(--surface-2); }
.g-task:hover .g-title { color: var(--brand-fg); }
.g-task.done .g-title { color: var(--done); text-decoration: line-through; }
.g-sub { color: var(--faint); flex: none; }
.g-group { background: var(--surface-2); border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--text-2); text-decoration: none; }
a.g-group:hover > span:last-child { text-decoration: underline; }
.g-pbar { z-index: 1; align-self: center; height: 4px; border-radius: 2px; background: var(--brand-mid); }
.g-bar {
  z-index: 2; align-self: center; min-width: 0; height: 20px; margin: 0 1px; padding: 0 7px; overflow: hidden;
  border: 0; border-radius: var(--r-sm); background: var(--brand-soft-2); color: var(--brand-fg);
  font-size: 11.5px; font-weight: 600; line-height: 20px; text-align: left; white-space: nowrap; cursor: pointer;
}
.g-bar span { display: block; overflow: hidden; text-overflow: ellipsis; }
.g-bar:hover { filter: brightness(.94); }
.g-bar.s-doing { background: var(--brand); color: #fff; }
.g-bar.s-hold { background: var(--warn-soft); color: var(--warn); }
.g-bar.s-done { background: var(--bg-muted); color: var(--done); }
.g-bar.over { background: var(--danger-soft); color: var(--danger); }
.g-bar.short { padding: 0; }
.g-bar.clip-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 3px solid color-mix(in srgb, currentColor 45%, transparent); }
.g-bar.clip-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 3px solid color-mix(in srgb, currentColor 45%, transparent); }

/* ===== ボード ===== */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(264px, 1fr); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
@media (max-width: 899px) { .board { grid-auto-columns: minmax(272px, 86%); scroll-snap-type: x mandatory; } .board-col { scroll-snap-align: start; } }
.board-col { min-width: 0; padding: 12px; border: 1px solid var(--edge); border-radius: var(--r-lg); background: var(--surface-2); }
.board-head { display: flex; align-items: center; gap: 8px; margin: 2px 4px 10px; font-size: 13px; font-weight: 700; }
.board-head .count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.board-head .hint { margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--muted); }
.board-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.board-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--faint); }
.board-list:not(:empty) + .board-empty { display: none; }
.bcard { min-width: 0; display: flex; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); transition: background .12s; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* ドラッグ中：元のカードは薄く、写し（ゴースト）が指についてくる。落とせる列は縁取りで示す */
.board.is-dragging { cursor: grabbing; }
.board.is-dragging .bcard-body, .board.is-dragging .check { cursor: grabbing; }
.bcard.dragging { opacity: .35; }
.drag-ghost { position: fixed; z-index: 70; margin: 0; pointer-events: none; opacity: .95; transform: rotate(1.5deg); outline: 2px solid var(--brand-fg); background: var(--surface); }
.board-col.over { background: var(--brand-soft-2); outline: 2px solid var(--brand-fg); outline-offset: -2px; }
.bcard:hover { background: var(--surface-2); }
.bcard .check { width: 40px; padding-top: 12px; }
.bcard-body { flex: 1; min-width: 0; padding: 12px 14px 12px 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.bcard .task-title { font-size: 14px; }
.bcard .meta { font-size: 12px; gap: 4px 10px; }
.bcard.done .task-title { color: var(--done); text-decoration: line-through; font-weight: 400; }

/* ===== プロジェクト管理（グループは線で囲み、中は塗らない。案件はカードで右上に件数） ===== */
.group-bar { margin: -4px 0 20px; }
.group-bar .fk { display: inline-flex; align-items: center; gap: 6px; width: auto; font-size: 13px; font-weight: 600; color: var(--muted); }
.pgroups { display: grid; gap: 20px; }
.pgroup { padding: 16px 18px 18px; border: 1.5px solid var(--line-strong); border-radius: 10px; }
.pgroup.closed { border-style: dashed; }
.pgroup-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 14px; }
.pgroup-head h2 { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; margin: 0; line-height: 1.4; }
.pgroup-head .sub { display: inline-flex; flex-wrap: wrap; gap: 0 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pgroup-head .sub .over { color: var(--danger); font-weight: 600; }
.pgroup .link-btn { margin-top: 10px; }
.pgroup .link-btn + .pcards { margin-top: 10px; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
@media (max-width: 640px) { .pgroup { padding: 14px 12px 14px; } .pcards { grid-template-columns: minmax(0, 1fr); gap: 10px; } }
.pcard {
  display: grid; gap: 10px; align-content: start; min-width: 0; padding: 14px 16px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: inherit; transition: background .1s;
}
.pcard:hover { background: var(--surface-2); }
.pcard.closed .pname { color: var(--muted); }
.ptop { display: flex; align-items: flex-start; gap: 12px; }
.pname { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.pcounts { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; font-size: 12.5px; line-height: 1.4; color: var(--muted); white-space: nowrap; }
.pcounts b { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pcounts .zero, .pcounts .zero b { color: var(--faint); font-weight: 500; }
.pcounts .over, .pcounts .over b { color: var(--danger); }
.ptags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--muted); }
.ptag { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 22px; padding: 0 8px 0 7px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
/* カード下段：売上・予算・粗利の3枠 */
.pfig { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.pfig.none { display: block; font-size: 12.5px; color: var(--faint); }
.fig { display: grid; gap: 2px; min-width: 0; }
.fig .fl { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.fig .fv { font-size: 14.5px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig .fv.faint { color: var(--faint); font-weight: 500; }
.fig .fv.neg { color: var(--danger); }
.fig .fs { min-height: 15px; font-size: 11.5px; color: var(--muted); line-height: 1.3; font-variant-numeric: tabular-nums; }
.pcard .progress { margin-top: -2px; max-width: none; }
.pnote { font-size: 14px; color: var(--text-2); white-space: pre-wrap; margin: -8px 0 20px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); }
.progress { display: flex; height: 4px; max-width: 360px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--bg-muted); }
.progress span { display: block; height: 100%; }
.progress .fixed { background: var(--brand); }
.progress .plan { background: var(--brand-mid); }
.progress.over .fixed { background: var(--danger); }

/* ===== カード（白い面。縁取りも影もなし） ===== */
.card { background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-lg); padding: 22px 26px; margin-bottom: 20px; }
@media (max-width: 640px) { .card { padding: 16px; } }
.card > h2 { font-size: 15px; font-weight: 700; margin: 0 0 4px; line-height: 1.5; }
.card .desc { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.card-head.sub { margin: 20px 0 10px; }
.card .table-wrap { border-radius: var(--r); border-color: var(--line); }
.card .list { background: var(--surface-2); border-color: var(--line); }
.card .list .task:hover { background: var(--bg-muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ===== 売上：グラフ（棒は単色の塗り分け。見込みは薄い同系色） ===== */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.legend i.fixed { background: var(--brand); }
.legend i.plan { background: var(--brand-mid); }
.legend i.cost { background: color-mix(in srgb, var(--danger) 45%, var(--surface)); }
.legend i.gp { height: 3px; border-radius: 1px; background: var(--gp); }
.ch { position: relative; height: 280px; }
.ch-grid { position: absolute; left: 52px; right: 0; top: 24px; bottom: 28px; pointer-events: none; }
.ch-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.ch-line.base { border-top-color: var(--line-strong); }
.ch-line span { position: absolute; right: calc(100% + 8px); transform: translateY(-50%); font-size: 11px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-plot { position: absolute; left: 52px; right: 0; top: 24px; bottom: 0; display: grid; grid-template-columns: repeat(var(--n, 12), minmax(0, 1fr)); }
.ch-col { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 0; background: none; cursor: pointer; color: inherit; }
.ch-col:hover { background: color-mix(in srgb, var(--hover) 80%, transparent); }
.ch-area { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; min-height: 0; }
.ch-stack { position: relative; display: flex; flex-direction: column; width: min(22px, 38%); min-height: 0; }
.ch-stack > i { display: block; min-height: 0; }
.ch-stack .fixed { background: var(--brand); }
.ch-stack .plan { background: var(--brand-mid); }
.ch-cost { width: min(22px, 38%); background: color-mix(in srgb, var(--danger) 45%, var(--surface)); }
.ch-val { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; font-style: normal; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-label { height: 28px; line-height: 28px; text-align: center; font-size: 12px; color: var(--muted); }
.ch-col.now .ch-label { color: var(--brand-fg); font-weight: 700; }
.ch-overlay { position: absolute; left: 0; right: 0; top: 0; bottom: 28px; pointer-events: none; }
.ch-overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ch-overlay polyline { fill: none; stroke: var(--gp); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--gp); transform: translate(-50%, 50%); }
.ch-empty { position: absolute; left: 52px; right: 0; top: 24px; bottom: 28px; display: grid; place-items: center; font-size: 13px; color: var(--muted); pointer-events: none; }
@media (max-width: 640px) {
  .ch { height: 230px; }
  .ch-grid, .ch-plot, .ch-empty { left: 40px; }
  .ch-val { display: none; }
  .ch-label { font-size: 11px; }
}

/* ===== 売上：内訳・月次表・明細 ===== */
.bd { display: grid; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) auto 52px; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.bd-row:first-child { border-top: 0; padding-top: 0; }
.bd-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; font-weight: 500; }
.bd-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-bar { height: 8px; border-radius: 2px; background: var(--bg-muted); overflow: hidden; }
.bd-bar span { display: block; height: 100%; background: var(--brand); }
.bd-amt { font-size: 13.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bd-share { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bd-none { font-size: 13px; color: var(--muted); margin: 0; padding: 16px 0; text-align: center; }
@media (max-width: 560px) { .bd-row { grid-template-columns: minmax(0, 1fr) auto 44px; } .bd-bar { grid-column: 1 / -1; grid-row: 2; } }

table.grid.money th[scope="row"] { font-weight: 500; color: var(--text); }
table.grid.money tr.gross > * { font-weight: 700; border-top: 2px solid var(--line-strong); }
table.grid.monthly tbody tr { cursor: pointer; }
table.grid.monthly tbody tr.now th { color: var(--brand-fg); font-weight: 700; }
table.grid.monthly .go { color: var(--faint); width: 32px; padding: 0 8px; }
table.grid.monthly tbody tr:hover .go { color: var(--brand-fg); }
table.grid.monthly .plan-tag { margin-left: 8px; height: 18px; font-size: 11px; }
@media (max-width: 560px) { table.grid.monthly .c-rate { display: none; } table.grid th, table.grid td { padding: 0 10px; } }

.entry {
  display: grid; grid-template-columns: 48px auto minmax(0, 1fr) auto; grid-template-areas: "date kind body amt";
  align-items: center; gap: 4px 12px; width: 100%; min-height: 56px; padding: 10px 16px;
  border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; color: inherit; transition: background .1s;
}
.entry:first-child { border-top: 0; }
.entry:hover { background: var(--surface-2); }
.e-date { grid-area: date; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry > .badge { grid-area: kind; }
.e-body { grid-area: body; min-width: 0; display: grid; }
.e-main { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; }
.e-sub .badge { height: 18px; font-size: 11px; }
.e-amt { grid-area: amt; font-size: 14px; font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .entry { grid-template-columns: 40px auto minmax(0, 1fr); grid-template-areas: "date kind amt" "body body body"; }
}

/* ===== 案件の月次の予算と実績（12か月の表。左の区分と見出しは固定、横にスクロール） ===== */
.pl-card .table-wrap { margin-bottom: 12px; }
table.grid.pl { min-width: 1120px; }
table.grid.pl th, table.grid.pl td { padding: 0 10px; }
table.grid.pl thead th:first-child, table.grid.pl tbody th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 76px; }
table.grid.pl thead th:first-child { z-index: 3; background: var(--surface-2); }
table.grid.pl tbody tr:hover > th[scope="row"] { background: var(--surface-2); }
table.grid.pl th.now, table.grid.pl td.now { background: var(--brand-soft); }
table.grid.pl .total { font-weight: 700; border-left: 2px solid var(--line-strong); }
table.grid.pl tr.rate > * { color: var(--muted); font-size: 12.5px; height: 36px; }
table.grid.pl tr.rate th { color: var(--text); }
table.grid.pl .input.cell { width: 96px; height: 30px; padding: 0 8px; font-size: 13px; }
.cell-btn { display: inline-block; min-width: 60px; padding: 4px 6px; margin: 0 -6px; border: 0; border-radius: var(--r-sm); background: none; color: inherit; font: inherit; font-variant-numeric: tabular-nums; text-align: right; cursor: pointer; }
.cell-btn:hover { background: var(--brand-soft-2); color: var(--brand-fg); }
.cell-btn.neg { color: var(--danger); }
.pl-sum { display: grid; gap: 8px; font-size: 13.5px; color: var(--muted); margin: 4px 0 8px; }
.pl-sum b { color: var(--text); }
.pl-sum .progress { max-width: none; height: 6px; border-radius: 3px; margin: 0; }
.input.mode { width: auto; min-width: 136px; }

/* ===== 詳細パネル・入力フォーム（覆いは単色、パネルは影なし） ===== */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
}
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 4px auto 14px; }
@media (min-width: 900px) {
  .sheet { left: auto; top: 0; bottom: 0; width: 560px; max-height: none; border-radius: 0; padding: 24px 28px; }
  .sheet .grab { display: none; }
}
.sheet-head { display: flex; align-items: flex-start; gap: 8px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.close { display: grid; place-items: center; flex: none; width: 36px; height: 36px; margin: -4px -8px 0 0; border: 0; border-radius: var(--r); background: none; cursor: pointer; color: var(--muted); }
.close:hover { background: var(--bg-muted); color: var(--text); }
.fields { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px 16px; margin: 16px 0 24px; font-size: 14px; line-height: 1.6; }
.fields dt { font-size: 13px; color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.status-row { display: grid; gap: 6px; margin: 0 0 16px; }
.status-row .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.status-row .seg { display: flex; }
.status-row .seg button { flex: 1; padding: 0 6px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.subhead { font-size: 14px; font-weight: 700; margin: 24px 0 8px; }
.history { font-size: 13px; color: var(--muted); margin: 0; padding-left: 18px; }

.form { display: grid; gap: 16px; margin-top: 16px; }
.form .field { display: grid; gap: 6px; min-width: 0; }
.form label, .form .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 560px) { .form .row2, .form .row3 { grid-template-columns: 1fr; } }
.form .seg { display: flex; width: 100%; }
.form .seg button { flex: 1; }
.form .actions { margin: 4px 0 0; }
.field-err { color: var(--danger); font-size: 13px; min-height: 1em; }
.field-hint { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin: 0; }
.form .static { font-size: 14px; color: var(--text-2); padding: 8px 0; }
.input.area { height: auto; min-height: 84px; padding: 9px 12px; line-height: 1.6; resize: vertical; font-family: inherit; }
/* くり返しの入力：種類の選択と、その詳細（曜日・日付）を横に */
.rep-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rep-row > select.input { width: auto; min-width: 120px; }
.rep-detail:empty { display: none; }
.rep-detail .frow { gap: 6px; }
.rep-detail .fk { width: auto; }
.rep-detail select.input { width: auto; }
.rep-detail .chip { height: 32px; padding: 0 11px; }
@media (pointer: coarse) { .rep-detail .chip { height: 40px; } }
/* 詳細パネルの上の操作（編集・小タスクを追加） */
.sheet-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.fields .pre { white-space: pre-wrap; font-size: 13.5px; line-height: 1.7; color: var(--text-2); }
/* くり返しの目印 */
.rep { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.rep-ico { display: inline-flex; vertical-align: middle; margin-left: 6px; color: var(--muted); }

/* ===== 設定 ===== */
.logo-preview { display: flex; align-items: center; min-height: 72px; padding: 16px; margin-bottom: 16px; border-radius: var(--r); background: var(--surface-2); }
.logo-preview img { max-height: 40px; max-width: 100%; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.swatch { width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r); cursor: pointer; }
@media (pointer: coarse) { .swatch { width: 44px; height: 44px; } }
.swatch[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 2px; }
input[type="color"] { width: var(--ctl-h); height: var(--ctl-h); padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.hex { width: 120px; height: var(--ctl-h); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); font-variant-numeric: tabular-nums; }
.hex:focus { outline: 2px solid var(--brand-fg); outline-offset: -1px; }
.input.fiscal { width: 140px; }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px 16px; font-size: 14px; margin: 0 0 16px; }
.kv dt { font-size: 13px; color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ===== ログイン（白い面を一枚。上端にメインカラー） ===== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login form { width: 100%; max-width: 380px; padding: 36px 32px; background: var(--surface); border: 1px solid var(--edge); border-top: 6px solid var(--brand); border-radius: var(--r-lg); }
.login .logo { display: block; height: 24px; width: auto; margin-bottom: 28px; }
.login h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.login p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.login input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); font-size: 15px; }
.login input:focus { outline: 2px solid var(--brand-fg); outline-offset: -1px; border-color: var(--brand-fg); }
.login .btn { width: 100%; height: 40px; margin-top: 24px; }
.login .err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 1em; }

/* ===== トースト ===== */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 32px); padding: 10px 16px;
  background: #15181d; color: #fff; border-radius: var(--r); font-size: 14px;
}
.toast button { border: 0; background: none; cursor: pointer; padding: 0 4px; min-height: 32px; color: var(--sub); font-weight: 700; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.loading { padding: 24px 4px; color: var(--muted); }

/* ===== 補足 ===== */
table.grid.tasks .c-due.over .cell-sub { color: inherit; opacity: .85; }
.side-user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px; margin: -6px; border-radius: var(--r); text-decoration: none; color: inherit; }
.side-user:hover { background: var(--on-brand-fill); }
.page-head .sub .row { gap: 8px; }
.empty .btn { margin-top: 12px; }
table.grid.money .c-name { width: 100%; min-width: 140px; max-width: 0; }
table.grid.money .c-name .where { max-width: 100%; }
a.cell-link { text-decoration: none; }

/* ===== v0.6.2：タスクの行はPCで横一行（名前 ｜ 取引先・期日・優先度を右詰め）。スマホは2段のまま ===== */
.task-main { min-width: 0; }
@media (min-width: 760px) {
  .task-body { display: grid; grid-template-columns: minmax(44%, 1fr) minmax(0, auto); align-items: center; gap: 4px 14px; padding-top: 12px; padding-bottom: 12px; }
  .task-body .meta { min-width: 0; }
  .task-body .meta > * { flex: 0 0 auto; white-space: nowrap; } /* 期日・優先度は折り返さない */
  .task-body .meta .where { flex: 0 1 auto; min-width: 96px; max-width: 240px; } /* 縮むのは取引先タグだけ（最低でも頭の数文字は見せる） */
  .task-body .meta { margin-top: 0; flex-wrap: nowrap; justify-content: flex-end; }
  .task-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .list .check { align-items: center; padding-top: 0; }
  .sheet .task-body { grid-template-columns: minmax(0, 1fr); }
  .sheet .task-body .meta { margin-top: 6px; flex-wrap: wrap; justify-content: flex-start; }
}
.bcard .check { align-items: flex-start; }

/* 表のグループ分け（区切り行） */
table.grid tr.grp > td { height: 38px; padding: 0 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.grp-name { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
a.grp-name:hover { text-decoration: underline; }
tr.grp .count { margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--bg-muted); border-radius: var(--r-sm); padding: 0 7px; line-height: 20px; font-variant-numeric: tabular-nums; }
.toolbar select.input.group { min-width: 150px; }

/* ===== v0.6.3：行の中で期日（カレンダー）と状態（プルダウン）を直接変える。詳細パネルは右端の「詳細」ボタン ===== */
.task-body, .bcard-body { cursor: default; }
.task > .btn.detail { flex: none; align-self: center; margin: 0 12px 0 4px; }
.btn.detail { height: 28px; padding: 0 6px 0 10px; gap: 2px; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.btn.detail:hover { color: var(--brand-fg); border-color: var(--line-strong); background: var(--surface-2); }
.due-ctl { position: relative; display: inline-flex; }
.due-input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.due-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 6px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; font-variant-numeric: tabular-nums;
}
.due-btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.due-btn.over { color: var(--danger); border-color: var(--danger-line); font-weight: 600; }
.due-btn.today { color: var(--warn); border-color: var(--warn-line); font-weight: 600; }
.due-btn.none { color: var(--faint); border-style: dashed; }
.task.done .due-btn, tr.done .due-btn { color: var(--done); border-color: var(--line); font-weight: 400; }
.status-sel {
  appearance: none; -webkit-appearance: none; height: 24px; padding: 0 20px 0 8px; border: 0; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer; background-color: var(--bg-muted); color: var(--text-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23646b76' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 5px center; background-size: 11px;
}
.status-sel.s-todo { color: var(--muted); }
.status-sel.s-doing { background-color: var(--brand-soft-2); color: var(--brand-fg); }
.status-sel.s-hold { background-color: var(--warn-soft); color: var(--warn); }
.status-sel.s-done { background-color: var(--ok-soft); color: var(--ok); }
.meta .kids { white-space: nowrap; }
@media (pointer: coarse) { .due-btn, .status-sel { height: 32px; } .btn.detail { height: 36px; } }
.cell-title { font-size: 14px; font-weight: 500; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid.tasks tr.done .cell-title { color: var(--done); text-decoration: line-through; font-weight: 400; }
table.grid.tasks .c-detail { width: 86px; text-align: right; padding-right: 10px; }
table.grid.tasks .c-due { width: 200px; }
table.grid.tasks .c-status { width: 108px; }
table.grid.tasks { min-width: 1100px; }
.bcard-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.bcard .meta .where { max-width: 100%; }

/* ===== v0.6.4（2026-10-21）新着タスク・その場の書き換え ===== */
/* タスク名のすぐ後ろに「今日登録」などの印（名前が長いときは名前の側が省略される） */
.title-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.title-line > .task-title, .title-line > .cell-title { min-width: 0; flex: 0 1 auto; }
.new-tag { flex: none; font-size: 11.5px; font-weight: 700; line-height: 18px; padding: 0 6px; border-radius: var(--r-sm); color: var(--ok); background: var(--ok-soft); white-space: nowrap; }
.task.done .new-tag, tr.done .new-tag, .bcard.done .new-tag { opacity: .6; }
.section-head.new { color: var(--ok); }
.section-head.new .count { background: var(--ok); color: #fff; }
.stat.new .v { color: var(--ok); }
.stat.new.zero .v { color: var(--faint); }
.more-btn { margin-top: 8px; }
/* 状態・期日を変えた行は、その場で薄く光らせて「ここが変わった」を知らせる（位置は動かさない） */
.just-changed { animation: just-changed 1.6s ease-out; }
@keyframes just-changed { from { background-color: var(--brand-soft-2); } }
/* スマホは横幅が足りないので、印をタスク名の上の行に出す（名前を押し縮めない） */
@media (max-width: 760px) {
  .title-line { flex-wrap: wrap; row-gap: 2px; }
  .title-line > .new-tag { order: -1; }
  .title-line > .task-title { flex-basis: 100%; }
}

/* ===== v0.6.5（2026-10-21）取引先タグの塗り・状態ごとの行の色・ガントの列幅 ===== */
/* 取引先タグ：タグ全体を取引先の色で塗る（色は取引先ごとに固定。四角の目印は塗りに置き換え） */
.where, .ptag.client {
  background: color-mix(in srgb, var(--c, var(--faint)) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--c, var(--faint)) 32%, var(--surface));
  color: color-mix(in srgb, var(--c, var(--text-2)) 82%, var(--text));
  font-weight: 600;
}
.where .cdot, .ptag.client .cdot { display: none; }
.where .proj { color: inherit; opacity: .85; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .where, :root:not([data-theme="light"]) .ptag.client {
    background: color-mix(in srgb, var(--c, var(--faint)) 30%, var(--surface));
    color: color-mix(in srgb, var(--c, var(--text-2)) 45%, #ffffff);
  }
}
:root[data-theme="dark"] .where, :root[data-theme="dark"] .ptag.client {
  background: color-mix(in srgb, var(--c, var(--faint)) 30%, var(--surface));
  color: color-mix(in srgb, var(--c, var(--text-2)) 45%, #ffffff);
}

/* 状態ごとに行（ブロック）全体を塗る：未着手＝白／進行中＝薄い緑（深緑を薄めると灰色に見えるので、明るい緑から作る）／保留＝薄い橙／完了＝薄い灰 */
.task.rs-doing, .bcard.rs-doing, table.grid.tasks tr.rs-doing > td { background: color-mix(in srgb, var(--ok) 11%, var(--surface)); }
.task.rs-hold, .bcard.rs-hold, table.grid.tasks tr.rs-hold > td { background: color-mix(in srgb, var(--warn) 11%, var(--surface)); }
.task.rs-done, .bcard.rs-done, table.grid.tasks tr.rs-done > td { background: var(--surface-2); }
.task.rs-doing:hover, table.grid.tasks tr.rs-doing:hover > td { background: color-mix(in srgb, var(--ok) 17%, var(--surface)); }
.task.rs-hold:hover, table.grid.tasks tr.rs-hold:hover > td { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); }
.task.rs-done:hover, table.grid.tasks tr.rs-done:hover > td { background: var(--bg-muted); }
.card .list .task.rs-todo { background: var(--surface); }
/* 塗った行の上でも状態のプルダウンが埋もれないよう、白地に枠線 */
.rs-doing .status-sel, .rs-hold .status-sel, .rs-done .status-sel { box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 30%, transparent); }
.rs-done .status-sel.s-done { background-color: var(--surface); }

/* ガント：タスク列の右端をドラッグして幅を変える */
.g-corner { justify-content: space-between; }
.g-resize { position: absolute; top: 0; right: -5px; z-index: 8; width: 10px; height: 100%; cursor: col-resize; touch-action: none; }
.g-resize::after { content: ''; position: absolute; top: 10px; bottom: 10px; left: 4px; width: 2px; border-radius: 1px; background: var(--line-strong); }
.g-resize:hover::after, .g-resize:focus-visible::after, .gantt.resizing .g-resize::after { background: var(--brand-fg); }
.gantt.resizing, .gantt.resizing * { cursor: col-resize !important; user-select: none; }
.g-name.g-child { padding-left: 22px; }
.g-name.g-parent .g-title { font-weight: 600; }

/* 設定：AI連携の鍵 */
.token-list { list-style: none; margin: 0 0 16px; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.token-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.token-list li:first-child { border-top: 0; }
.tk-main { flex: 1; min-width: 0; }
.tk-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tk-new .input { flex: 1; min-width: 0; max-width: 360px; }
.token-out { margin-top: 16px; display: grid; gap: 12px; }
.warn-note { margin: 0; padding: 10px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; }
.code-box { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px 6px 14px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); }
pre.code { margin: 0; padding: 12px 14px; font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ===== v0.8（2026-10-21）メモ ===== */
/* 種類の色（議事録＝青系・記録＝緑系・ナレッジ＝紫系・マニュアル＝橙系・メモ＝灰） */
.badge.nk { font-weight: 600; }
.badge.nk-minutes { background: color-mix(in srgb, #3b5b92 14%, var(--surface)); color: color-mix(in srgb, #3b5b92 85%, var(--text)); }
.badge.nk-record { background: color-mix(in srgb, #2f6f5e 14%, var(--surface)); color: color-mix(in srgb, #2f6f5e 85%, var(--text)); }
.badge.nk-know { background: color-mix(in srgb, #7b4f96 14%, var(--surface)); color: color-mix(in srgb, #7b4f96 85%, var(--text)); }
.badge.nk-manual { background: var(--warn-soft); color: var(--warn); }
.kind-seg { margin: -4px 0 16px; overflow-x: auto; }
.kind-seg .seg { flex-wrap: nowrap; }

/* 一覧 */
.list.notes { overflow: hidden; }
.note-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; transition: background .1s; }
.note-row:first-child { border-top: 0; }
.note-row:hover { background: var(--surface-2); }
.nr-main { flex: 1; min-width: 0; }
.nr-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; line-height: 1.5; }
.nr-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-title .pin { color: var(--warn); flex: none; }
.nr-excerpt { margin-top: 2px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-meta { display: flex; align-items: center; gap: 8px; flex: none; max-width: 52%; min-width: 0; }
.nr-meta .where { max-width: 220px; }
.nr-date { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.ntag { font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 760px) {
  .note-row { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
  .nr-meta { max-width: none; flex-wrap: wrap; }
  .nr-date { margin-left: auto; min-width: 0; }
}
.section-head.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* メモのページ（Notion のように、白い紙に大きなタイトル） */
.note-page { max-width: 860px; margin: 0 auto; }
.note-top { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 18px; }
.crumb-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); text-decoration: none; }
.crumb-link:hover { color: var(--text); }
.note-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.save-state { font-size: 12px; color: var(--faint); min-width: 72px; text-align: right; }
.note-title {
  display: block; width: 100%; resize: none; overflow: hidden; border: 0; outline: 0; padding: 0; margin: 0 0 14px;
  background: transparent; color: var(--text); font: inherit; font-size: clamp(24px, 2vw + 16px, 34px); font-weight: 700; line-height: 1.3; letter-spacing: -.01em;
}
.note-title::placeholder { color: var(--faint); }
.note-props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 24px; padding: 4px 0 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .note-props { grid-template-columns: minmax(0, 1fr); } }
.prop-row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.prop-row .pk { flex: none; width: 40px; font-size: 13px; color: var(--muted); }
.input.prop { height: 34px; border-color: transparent; background: transparent; padding: 0 8px; }
.input.prop:hover { background: var(--surface-2); }
.input.prop:focus { background: var(--surface); }
.note-editor {
  display: block; width: 100%; min-height: 240px; resize: vertical; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; line-height: 1.85;
}
.note-editor:focus { outline: 2px solid var(--brand-fg); outline-offset: -1px; border-color: var(--brand-fg); }
.note-foot { margin: 28px 0 0; font-size: 12px; color: var(--faint); }
.note-foot a { color: var(--muted); }


/* ===== v0.9 AI連携（コネクタ）の手順 ===== */
.card .subhead { font-size: 14px; font-weight: 700; margin: 20px 0 8px; }
.card ol.steps { margin: 0 0 12px; padding-left: 1.4em; font-size: 14px; line-height: 1.8; }
.tk-manual { margin-top: 12px; }
.tk-manual summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.tk-manual[open] summary { margin-bottom: 10px; }

/* ===== v0.9 メモの本文：Notion のようなブロック編集（public/editor.js） ===== */
:root {
  --nc-gray: #787774; --nc-brown: #9f6b53; --nc-orange: #d9730d; --nc-yellow: #cb912f; --nc-green: #448361;
  --nc-blue: #337ea9; --nc-purple: #9065b0; --nc-pink: #c14c8a; --nc-red: #d44c47;
  --nc-mark: color-mix(in srgb, var(--sub) 42%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nc-gray: #9b9b9b; --nc-brown: #ba856f; --nc-orange: #e0894a; --nc-yellow: #d8a656; --nc-green: #5fae80;
    --nc-blue: #6a95d6; --nc-purple: #a97ad8; --nc-pink: #d9679f; --nc-red: #e5605b;
    --nc-mark: color-mix(in srgb, var(--sub) 30%, transparent);
  }
}
:root[data-theme="dark"] {
  --nc-gray: #9b9b9b; --nc-brown: #ba856f; --nc-orange: #e0894a; --nc-yellow: #d8a656; --nc-green: #5fae80;
  --nc-blue: #6a95d6; --nc-purple: #a97ad8; --nc-pink: #d9679f; --nc-red: #e5605b;
  --nc-mark: color-mix(in srgb, var(--sub) 30%, transparent);
}
.note-blocks { min-height: 160px; }
.ne { position: relative; font-size: 15px; line-height: 1.75; color: var(--text); }
.ne-list { display: flow-root; }
.ne-block { position: relative; display: flex; align-items: flex-start; margin-left: calc(var(--ind, 0) * 26px); padding: 1px 0; border-radius: var(--r-sm); }
.ne-hidden { display: none; }
.ne-tail { min-height: 140px; cursor: text; }

/* 左の「＋」と「⋮⋮」（マウスを乗せたブロックだけ出す） */
.ne-gutter { position: absolute; left: -42px; top: 3px; display: flex; gap: 0; opacity: 0; transition: opacity .12s; user-select: none; }
.ne-block:hover > .ne-gutter, .ne-block:focus-within > .ne-gutter { opacity: 1; }
.ne-dragging .ne-gutter { opacity: 0 !important; }
.ne-add, .ne-handle {
  width: 20px; height: 24px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--faint);
  font-size: 16px; line-height: 24px; cursor: pointer; display: grid; place-items: center;
}
.ne-handle { font-size: 11px; letter-spacing: -2px; cursor: grab; touch-action: none; }
.ne-add:hover, .ne-handle:hover { background: var(--hover); color: var(--text-2); }
.t-h1 > .ne-gutter { top: 25px; }
.t-h2 > .ne-gutter { top: 18px; }
.t-h3 > .ne-gutter { top: 11px; }
.t-callout > .ne-gutter { top: 14px; }
.t-code > .ne-gutter, .t-raw > .ne-gutter, .t-table > .ne-gutter { top: 6px; }
.t-hr > .ne-gutter { top: 5px; }

/* 文字の入る所 */
.ne-text { flex: 1; min-width: 0; padding: 3px 2px; outline: 0; white-space: pre-wrap; overflow-wrap: anywhere; caret-color: var(--text); }
.ne-text:empty::before { color: var(--faint); pointer-events: none; }
.t-p .ne-text:empty:focus::before, .ne-block:not(.t-p) > .ne-text:empty::before, .ne-box > .ne-text:empty::before,
.ne-list > .ne-block.t-p:only-child > .ne-text:empty::before { content: attr(data-ph); }
.t-h1 > .ne-text { font-size: 26px; font-weight: 700; line-height: 1.35; margin-top: 20px; letter-spacing: -.01em; }
.t-h2 > .ne-text { font-size: 21px; font-weight: 700; line-height: 1.4; margin-top: 14px; }
.t-h3 > .ne-text { font-size: 17px; font-weight: 700; line-height: 1.45; margin-top: 8px; }
.ne-list > .ne-block:first-child > .ne-text { margin-top: 0; }
.ne-list > .ne-block.t-h1:first-child > .ne-gutter { top: 5px; }
.ne-list > .ne-block.t-h2:first-child > .ne-gutter { top: 4px; }
.ne-list > .ne-block.t-h3:first-child > .ne-gutter { top: 3px; }

/* 箇条書き・番号・チェック・トグルの頭 */
.ne-prefix { flex: none; width: 26px; min-height: calc(1.75em + 6px); display: flex; justify-content: center; align-items: flex-start; padding-top: 3px; user-select: none; color: var(--text-2); }
.t-ol > .ne-prefix { justify-content: flex-end; padding-right: 6px; font-variant-numeric: tabular-nums; }
.ne-bullet { font-size: 1.2em; line-height: 1.45; }
.ne-check { width: 16px; height: 16px; margin: .42em 0 0; accent-color: var(--brand); cursor: pointer; }
.t-todo.done > .ne-text { color: var(--done); text-decoration: line-through; }
.ne-arrow { width: 22px; height: 22px; margin-top: 2px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-2); font-size: 10px; cursor: pointer; transition: transform .15s; }
.ne-arrow:hover { background: var(--hover); }
.ne-arrow.open { transform: rotate(90deg); }

/* 引用・コールアウト */
.ne-box { flex: 1; min-width: 0; display: flex; align-items: flex-start; }
.t-quote > .ne-box { border-left: 3px solid var(--text); padding-left: 12px; margin: 2px 0; }
.t-quote .ne-text { font-size: 15.5px; }
.t-callout > .ne-box { gap: 6px; padding: 12px 14px 12px 10px; margin: 4px 0; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); }
.ne-emoji { flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; font-size: 18px; line-height: 28px; cursor: pointer; }
.ne-emoji:hover { background: var(--hover); }

/* コード・HTML（そのまま保存する部分） */
.ne-codebox { flex: 1; min-width: 0; margin: 4px 0; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.ne-codehead { display: flex; justify-content: flex-start; padding: 6px 8px 0; }
.ne-lang { height: 24px; padding: 0 4px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.ne-lang:hover { background: var(--hover); }
.ne-code { margin: 0; padding: 6px 14px 12px; outline: 0; overflow-x: auto; white-space: pre; tab-size: 2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6; color: var(--text); min-height: 1.6em; }
.ne-raw { padding-top: 10px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }

/* 表 */
.ne-tablebox { flex: 1; min-width: 0; margin: 4px 0; overflow-x: auto; }
.ne-table { border-collapse: collapse; font-size: 14px; }
.ne-table th, .ne-table td { min-width: 110px; padding: 0; border: 1px solid var(--line-strong); vertical-align: top; text-align: left; }
.ne-table th { background: var(--surface-2); font-weight: 600; }
.ne-cell { padding: 6px 10px; outline: 0; min-height: calc(1.6em + 12px); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.ne-cell:focus { box-shadow: inset 0 0 0 2px var(--brand-line); }
.ne-tabletools { display: flex; gap: 4px; margin-top: 4px; opacity: 0; transition: opacity .12s; }
.ne-block:hover .ne-tabletools, .ne-block:focus-within .ne-tabletools { opacity: 1; }
.ne-tabletools button { height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--muted); font-size: 12px; cursor: pointer; }
.ne-tabletools button:hover { color: var(--text); background: var(--hover); }

/* 区切り線 */
.ne-hr { flex: 1; padding: 12px 0; outline: 0; cursor: default; border-radius: var(--r-sm); }
.ne-hr hr { margin: 0; border: 0; border-top: 1px solid var(--line-strong); }
.ne-hr:focus { background: var(--brand-soft); }

/* 文の中の飾り */
.ne strong, .ne b { font-weight: 700; }
.ne mark { background: var(--nc-mark); color: inherit; padding: 0 1px; border-radius: 2px; }
.ne :not(pre) > code { padding: 1px 5px; border-radius: 4px; background: var(--bg-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; color: var(--nc-red); }
.ne a { color: var(--brand-fg); text-decoration: underline; text-decoration-color: var(--brand-line); cursor: text; }
.ne a:hover { text-decoration-color: currentColor; }
[data-color="gray"] { color: var(--nc-gray); }
[data-color="brown"] { color: var(--nc-brown); }
[data-color="orange"] { color: var(--nc-orange); }
[data-color="yellow"] { color: var(--nc-yellow); }
[data-color="green"] { color: var(--nc-green); }
[data-color="blue"] { color: var(--nc-blue); }
[data-color="purple"] { color: var(--nc-purple); }
[data-color="pink"] { color: var(--nc-pink); }
[data-color="red"] { color: var(--nc-red); }

/* 並べ替え中 */
.ne-dragging, .ne-dragging * { cursor: grabbing !important; user-select: none; }
.ne-lifted { opacity: .35; }
.ne-dropline { position: fixed; z-index: 62; height: 3px; margin-top: -1px; border-radius: 2px; background: var(--brand-fg); opacity: .75; pointer-events: none; }

/* 「/」のメニュー・ブロックのメニュー */
.ne-pop {
  position: fixed; z-index: 60; width: 290px; max-height: min(360px, 60vh); overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--edge); border-radius: 8px; box-shadow: 0 10px 32px rgba(15, 20, 25, .18);
}
.ne-pop[hidden], .ne-bar[hidden], .ne-colors[hidden] { display: none; }
.ne-menu { width: 250px; }
.ne-pop-title { padding: 8px 8px 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.ne-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; cursor: pointer; }
.ne-item:hover, .ne-item.on { background: var(--hover); }
.ne-item.danger { color: var(--danger); }
.ne-ico { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600; }
.ne-menu .ne-ico { width: 24px; height: 24px; border: 0; background: none; }
.ne-lbl { display: grid; min-width: 0; line-height: 1.3; }
.ne-lbl b { font-size: 14px; font-weight: 500; }
.ne-lbl small { font-size: 12px; color: var(--muted); }

/* 文字を選んだときの飾りの帯 */
.ne-bar {
  position: fixed; z-index: 61; display: flex; align-items: center; gap: 2px; padding: 4px; max-width: calc(100vw - 16px); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--edge); border-radius: 8px; box-shadow: 0 8px 26px rgba(15, 20, 25, .18);
}
.ne-bar > button { min-width: 32px; height: 30px; padding: 0 6px; border: 0; border-radius: 5px; background: none; color: var(--text); font-size: 14px; cursor: pointer; }
.ne-bar > button:hover { background: var(--hover); }
.ne-bar mark { background: var(--nc-mark); padding: 0 3px; }
.ne-colorA { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--nc-red); }
.ne-colors {
  position: absolute; top: calc(100% + 6px); right: 0; width: 230px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--edge); border-radius: 8px; box-shadow: 0 8px 26px rgba(15, 20, 25, .18);
}
.ne-colors button { padding: 6px 8px; border: 0; border-radius: 5px; background: none; color: var(--text); text-align: left; font-size: 13px; cursor: pointer; }
.ne-colors button:hover { background: var(--hover); }
.ne-colors span[data-color] { font-weight: 700; }
.ne-linkin { width: min(280px, 70vw); height: 30px; margin: 0 2px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.ne-linkin:focus { outline: 2px solid var(--brand-fg); outline-offset: -1px; }

/* スマホ・タブレット（マウスなし）：左に少し余白を取り、選んでいるブロックだけ「⋮⋮」を出す */
@media (hover: none), (max-width: 640px) {
  .ne { padding-left: 24px; }
  .ne-gutter { left: -26px; }
  .ne-add { display: none; }
  .ne-block:hover > .ne-gutter { opacity: 0; }
  .ne-block:focus-within > .ne-gutter { opacity: .8; }
  .ne-handle { width: 24px; height: 28px; font-size: 12px; }
  .ne-tabletools { opacity: 1; }
  .t-h1 > .ne-text { font-size: 23px; }
  .t-h2 > .ne-text { font-size: 19px; }
}
