:root {
  --bg: #f6f8f3;
  --panel: #ffffff;
  --panel-2: #fbfcf9;
  --ink: #163c35;
  --ink-2: #3f5d56;
  --muted: #72847f;
  --line: #e1e9e2;
  --line-2: #cfdcd3;
  --accent: #c0ed50;
  --accent-ink: #173f35;
  --focus: rgba(120, 170, 60, .35);
  --select: #f1f8dc;
  --mark: #f4ee8a;
  --k-decision: #2f7d4f;
  --k-spec: #2c6fa3;
  --k-knowledge: #6a5bb0;
  --k-idea: #b8457a;
  --k-issue: #b03a48;
  --k-todo: #c2572b;
  --k-progress: #a0791b;
  --k-meeting: #1f8a86;
  --k-image: #8a5a2b;
  --k-other: #6b7c78;
  --late: #c43d2b;
  --soon: #a0791b;
  --shadow: 0 1px 2px rgba(22, 60, 53, .06), 0 6px 20px rgba(22, 60, 53, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121715; --panel: #181f1c; --panel-2: #1c2421; --ink: #e5eee9; --ink-2: #bccbc4;
    --muted: #8b9c96; --line: #26302c; --line-2: #34413b; --accent: #b6e24a; --accent-ink: #13241e;
    --focus: rgba(182, 226, 74, .3); --select: #233125; --mark: #5b5720;
    --k-decision: #6fcb92; --k-spec: #6fb2e6; --k-knowledge: #a89af0; --k-idea: #f08cbb; --k-issue: #f07c88; --k-todo: #f09a70;
    --k-progress: #e0bb5c; --k-meeting: #5fd0ca; --k-image: #d8a86a; --k-other: #9aaba5;
    --late: #f08470; --soon: #e0bb5c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* display を指定した要素でも hidden 属性で確実に消す */
[hidden] { display: none !important; }
/* iPhone の Safari が長い文章だけ勝手に拡大するのを止める (「意味が近い記憶」の一部が巨大になっていた) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--muted);
}
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ---- top bar ---- */
.topbar {
  flex: none; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink-2); text-decoration: none; font-size: 15px; white-space: nowrap; }
.brand b { color: var(--ink); }
.brand-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); box-shadow: inset 0 0 0 4px var(--accent), inset 0 0 0 7px var(--ink); }
.search { position: relative; flex: 1; max-width: 640px; }
.search input {
  width: 100%; padding: 9px 36px 9px 14px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--panel-2); outline: none;
}
.search input:focus { border-color: var(--k-decision); box-shadow: 0 0 0 3px var(--focus); background: var(--panel); }
.search-hint { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:focus + .search-hint, .search input:not(:placeholder-shown) + .search-hint { display: none; }
.ghost { border: 1px solid var(--line-2); background: transparent; border-radius: 8px; padding: 6px 10px; color: var(--ink-2); }
.ghost:hover { background: var(--panel-2); color: var(--ink); }
.ghost.small { padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 16px; font-weight: 700; }
#key-button { margin-left: 0; }
.topbar .views { margin-left: auto; }

/* ---- layout ---- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px minmax(320px, 440px) 1fr; }
.filters { overflow-y: auto; padding: 18px 16px 40px; border-right: 1px solid var(--line); }
.filters section + section { margin-top: 22px; }
/* 隠れた欄の後ろでも間隔が崩れないよう、表示中の欄の先頭は詰める */
.filters .for-tasks + .for-memories { margin-top: 0; }
/* 狭い画面で重ねて開いたときだけ出す、閉じるボタンの帯 */
.filters-bar { display: none; }
.filters.open .filters-bar {
  position: sticky; top: -18px; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  margin: -18px -16px 14px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.filters.open .filters-bar h2 { margin: 0; }
.filters h2 { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel); font-size: 12px; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.chip .n { font-size: 11px; opacity: .65; font-variant-numeric: tabular-nums; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--kc, var(--k-other)); }

/* ---- list ---- */
.list-pane { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel-2); }
.list-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: color-mix(in srgb, var(--panel-2) 92%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.list-summary { margin: 0; font-size: 12px; color: var(--muted); }
.list-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-toggle { display: none; }
select { border: 1px solid var(--line-2); border-radius: 8px; padding: 4px 6px; background: var(--panel); font-size: 12px; }
/* 草: 日ごとに書いた・更新した数 */
.grass { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.grass-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 11.5px; color: var(--muted); }
.grass-head b { color: var(--ink); font-variant-numeric: tabular-nums; }
.grass-legend { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.grass-body { display: flex; gap: 4px; }
.grass-wd { display: grid; grid-template-rows: 14px repeat(7, 11px); row-gap: 3px; width: 18px; font-size: 9.5px; line-height: 11px; color: var(--muted); }
.grass-months { display: grid; grid-template-columns: repeat(var(--weeks), 11px); column-gap: 3px; height: 14px; font-size: 9.5px; line-height: 11px; color: var(--muted); }
.grass-months span { white-space: nowrap; grid-row: 1; }
.grass-grid { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; margin-top: 3px; }
.gc { display: block; width: 11px; height: 11px; padding: 0; border: 0; border-radius: 2.5px; background: var(--line); }
i.gc { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.gc.l1 { background: color-mix(in srgb, var(--k-decision) 32%, var(--panel-2)); }
.gc.l2 { background: color-mix(in srgb, var(--k-decision) 55%, var(--panel-2)); }
.gc.l3 { background: color-mix(in srgb, var(--k-decision) 78%, var(--panel-2)); }
.gc.l4 { background: var(--k-decision); }
.gc.future { background: transparent; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.active-filters:not(:empty) { padding: 10px 14px 0; }
.memory-list { list-style: none; margin: 0; padding: 8px; }
.memory {
  display: block; width: 100%; text-align: left; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 12px; background: transparent; color: inherit;
}
.memory:hover { background: var(--panel); border-color: var(--line); }
.memory[aria-current="true"] { background: var(--select); border-color: var(--line-2); }
.memory-top { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.memory-top .id { font-variant-numeric: tabular-nums; }
.memory-top .date { margin-left: auto; }
.memory h3 { margin: 3px 0 2px; font-size: 14px; font-weight: 700; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.memory p { margin: 0; font-size: 12.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kind { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--kc, var(--k-other)); }
.kind::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.empty { padding: 30px 20px; text-align: center; color: var(--muted); }
/* 画像の一覧: 正方形寄りのタイル。object-fit: contain で全体を見せる */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.image-tile {
  display: grid; gap: 5px; width: 100%; text-align: left; border: 1px solid transparent; border-radius: 10px;
  padding: 6px; background: transparent; color: inherit;
}
.image-tile:hover { background: var(--panel); border-color: var(--line); }
.image-tile[aria-current="true"] { background: var(--select); border-color: var(--line-2); }
.image-thumb { display: grid; place-items: center; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 8px; background: var(--line); }
.image-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-cap { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.image-cap b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-cap .id { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- detail ---- */
.detail-pane { min-width: 0; overflow-y: auto; overflow-x: hidden; background: var(--panel); }
.detail-empty { height: 100%; display: grid; place-content: center; text-align: center; padding: 20px; color: var(--ink-2); }
.detail-empty p { margin: 4px 0; }
.detail { max-width: 760px; margin: 0 auto; padding: 26px 32px 60px; }
.detail-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.detail-bar .spacer { flex: 1; }
.back { display: none; }
/* 詳細から別の詳細へ移ったときだけ出る「← 戻り先」。長い名前は 1 行で省略する */
.back-to { max-width: 42%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail h1 { margin: 0 0 10px; font-size: 20px; line-height: 1.5; letter-spacing: -.01em; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 18px; font-size: 12px; color: var(--muted); }
.meta b { color: var(--ink-2); font-weight: 600; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.9; }
.body a, .related a { color: var(--k-spec); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--k-spec) 40%, transparent); }
.body a:hover { border-bottom-color: currentColor; }
.body a.missing { color: var(--muted); border-bottom-style: dashed; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 22px 0 0; }
.related { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); }
.related h2, .backlinks h2 { margin: 0 0 8px; font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.related ul, .backlinks ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
/* 長い見出しで行が幅を超えて伸びないように (… で切る) */
.related li, .backlinks li { min-width: 0; }
.related li a, .backlinks li a {
  display: flex; gap: 10px; align-items: baseline; padding: 7px 8px; margin: 0 -8px; border: 0; border-radius: 8px; color: var(--ink);
  text-decoration: none; min-width: 0;
}
.related li a:hover, .backlinks li a:hover { background: var(--panel-2); }
.related .rid, .backlinks .rid { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 58px; }
.related .rt, .backlinks .rt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.backlinks { margin-top: 26px; }

/* ---- dialog ---- */
.key-dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(420px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.key-dialog::backdrop { background: rgba(10, 20, 16, .45); }
.key-dialog form { padding: 22px; }
.key-dialog h2 { margin: 0 0 6px; font-size: 16px; }
.key-dialog p { margin: 0 0 14px; font-size: 13px; }
.key-dialog input { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel-2); outline: none; }
.key-dialog input:focus { box-shadow: 0 0 0 3px var(--focus); }
.error { color: var(--k-todo); min-height: 1.2em; margin: 8px 0 0 !important; font-size: 12px; }
.dialog-actions { display: flex; justify-content: space-between; margin-top: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 8px 14px; border-radius: 9px;
  background: var(--ink); color: var(--panel); font-size: 13px; box-shadow: var(--shadow); z-index: 10;
}

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(300px, 400px) 1fr; }
  .filters { display: none; }
  .filters.open { display: block; position: fixed; inset: 57px auto 0 0; width: 260px; z-index: 5; background: var(--panel); box-shadow: var(--shadow); }
  .filter-toggle { display: inline-block; }
}
@media (max-width: 720px) {
  .topbar { padding: 8px 16px; gap: 10px; }
  .brand { font-size: 0; gap: 0; }
  .search-hint { display: none; }
  .layout { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .detail-pane { display: none; }
  body.reading .list-pane { display: none; }
  body.reading .detail-pane { display: block; }
  .detail { padding: 16px 16px 60px; }
  .back { display: inline-block; }
  [data-copy="cmd"], .detail-bar > span:not(.spacer):not(.kind) { display: none; }
  .filters.open { inset: 104px 0 auto 0; width: auto; max-height: 70vh; border-bottom: 1px solid var(--line); }
}

/* ---- views (知識 / リスト / ボード / カレンダー) ---- */
.views { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--line); }
.views button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 7px; padding: 4px 11px;
  background: transparent; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.views button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 60, 53, .12); }
.views .lbl-short { display: none; }
.badge {
  min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--line-2); color: var(--ink-2);
  font-size: 11px; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums;
}
.badge.late { background: var(--late); color: #fff; }
.filters .for-tasks { display: none; }
.view-tasks .filters .for-tasks { display: block; }
.view-tasks .filters .for-memories { display: none; }
.filters .for-cards { display: none; }
.view-cards .filters .for-cards { display: block; }
.view-cards .filters .for-memories { display: none; }
.small-note { margin: 4px 0 0; width: 100%; font-size: 11px; }

.due { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.due.late { color: var(--late); }
.due.soon { color: var(--soon); }


/* ---- task box in detail ---- */
.task-box {
  margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2);
}
.task-box dl { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; font-size: 13px; }
.task-box dt { font-size: 11px; color: var(--muted); }
.task-box dd { margin: 0; font-weight: 600; }
.task-box .status { font-weight: 700; }
.task-next { margin: 10px 0 0; font-size: 14px; font-weight: 600; line-height: 1.6; }
.task-next span { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.task-box button { margin-top: 10px; }

/* 詳細の状態ボタン: 4 つの状態を並べ、今の状態は押せない */
.status-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.status-seg button { margin-top: 0; padding: 3px 10px; }
.status-seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); font-weight: 700; }
.status-seg button:disabled { cursor: default; opacity: .55; }
.status-seg button[aria-pressed="true"]:disabled { opacity: 1; }

/* 詳細の担当ボタン: 先頭の「未定」と、チームのメンバー。押されている人は人の色 */
.assignee-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.assignee-seg button { display: inline-flex; align-items: center; gap: 5px; margin-top: 0; padding: 3px 10px; }
.assignee-seg button .avatar { margin: 0; }
.assignee-seg button[aria-pressed="true"] { background: var(--ac, var(--ink)); border-color: var(--ac, var(--ink)); color: var(--panel); font-weight: 700; }
.assignee-seg button:disabled { cursor: default; opacity: .55; }
.assignee-seg button[aria-pressed="true"]:disabled { opacity: 1; }

@media (max-width: 720px) {
  /* 担当ボタンは折り返して、指でも押せる大きさにする */
  .task-box dl { gap: 8px; }
  .assignee-seg button { padding: 5px 11px; font-size: 13px; }
}

/* ---- board (カンバン) ---- */
.board-pane, .table-pane, .calendar-pane, .cards-pane { display: none; min-width: 0; min-height: 0; overflow: hidden; flex-direction: column; background: var(--panel-2); }
.view-wide .layout { grid-template-columns: 220px 1fr; }
.view-wide .list-pane { display: none; }
.view-board .board-pane { display: flex; }
.board-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
}
.board-head p { margin: 0; font-size: 12px; color: var(--muted); }
.board {
  /* 行の高さを画面に合わせる。auto のままだと列が中身の高さまで伸び、列の中でスクロールできない */
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr));
  grid-template-rows: minmax(0, 1fr); gap: 14px;
  padding: 14px 18px 18px; overflow-x: auto;
}
.column { display: flex; flex-direction: column; min-height: 0; border-radius: 12px; background: var(--line); background: color-mix(in srgb, var(--line) 55%, transparent); }
.column h2 {
  flex: none; display: flex; align-items: center; gap: 7px; margin: 0; padding: 11px 12px 8px;
  font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.column h2 .n { margin-left: auto; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.column .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.c-doing .dot { background: var(--k-spec); }
.c-blocked .dot { background: var(--soon); }
.c-done .dot { background: var(--k-decision); }
.column-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 8px; padding: 0 8px 10px; }
.column-empty { margin: 4px; font-size: 12px; color: var(--muted); }
.card {
  display: grid; gap: 6px; width: 100%; text-align: left; padding: 10px 12px; color: inherit;
  border: 1px solid var(--line); border-left: 3px solid transparent; border-radius: 10px; background: var(--panel);
  box-shadow: 0 1px 2px rgba(22, 60, 53, .06);
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.card[aria-current="true"] { border-color: var(--k-decision); box-shadow: 0 0 0 3px var(--focus); }
.card.overdue { border-left-color: var(--late); }
.card-top { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.card-top .due { margin-left: auto; }
.card h3 { margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card p { margin: 0; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.s-done h3 { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.card-foot { display: flex; align-items: center; min-width: 0; }
.card-foot .names { margin-left: 6px; font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot .names:first-child { margin-left: 0; color: var(--muted); }

/* ボードのドラッグ: 元のカード・ゴースト・ドロップ先・送信中 */
.card.dragging { opacity: .4; }
.card.saving { opacity: .55; pointer-events: none; }
.drag-ghost {
  position: fixed; left: 0; top: 0; margin: 0; z-index: 30; pointer-events: none;
  opacity: .95; box-shadow: var(--shadow);
}
.column.drop-target { background: color-mix(in srgb, var(--k-decision) 18%, var(--panel)); box-shadow: inset 0 0 0 2px var(--k-decision); }
.column.drop-target .column-empty { color: var(--k-decision); }
body.dragging-card { user-select: none; -webkit-user-select: none; }
/* マウスとペンの環境だけ。タッチでは今までどおり */
@media (hover: hover) and (pointer: fine) {
  .card { cursor: grab; }
  .card.dragging { cursor: grabbing; }
  body.dragging-card { cursor: grabbing; }
}

.avatar {
  flex: none; display: inline-grid; place-content: center; width: 20px; height: 20px; border-radius: 50%;
  margin-right: -4px; border: 2px solid var(--panel); font-size: 10px; font-weight: 700; color: #fff;
  background: var(--av, hsl(var(--h) 45% 42%));
}

/* リストとボードでは詳細を右から重ねる */
.view-wide .detail-pane {
  display: none; position: fixed; top: 57px; right: 0; bottom: 0; width: min(680px, 100vw); z-index: 4;
  border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(22, 60, 53, .12);
}
.view-wide.reading .detail-pane { display: block; }
.view-wide .back { display: inline-block; }

@media (max-width: 1100px) {
  .view-wide .layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar .views { order: 3; width: 100%; margin-left: 0; }
  /* 5 つのタブを 1 行に収める。長い名前は短くし、余白を詰める */
  .topbar .views button { flex: 1 1 auto; justify-content: center; padding: 5px 4px; font-size: 12px; gap: 3px; }
  .topbar .views .lbl-long { display: none; }
  .topbar .views .lbl-short { display: inline; }
  .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; padding: 12px 16px; }
  .column { scroll-snap-align: start; }
  .board-head { padding: 10px 16px; }
  .view-wide .detail-pane { top: 0; width: 100vw; z-index: 6; }
  .view-wide.reading .board-pane, .view-wide.reading .table-pane, .view-wide.reading .calendar-pane, .view-wide.reading .cards-pane { display: none; }
}

/* ---- list (表) ---- */
.view-table .table-pane { display: flex; }
/* 上の余白は表の margin で取る。wrap の padding だと、固定した見出しの上に行が透けて見える */
.tlist-wrap { flex: 1; min-height: 0; overflow: auto; padding: 0 18px 24px; }
.tlist {
  margin-top: 14px; min-width: 760px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: clip;
}
.thead, .trow {
  display: grid; grid-template-columns: 40px minmax(280px, 1fr) minmax(140px, 200px) 120px 76px 64px;
  align-items: center; column-gap: 12px; padding: 0 14px;
}
.thead {
  position: sticky; top: 0; z-index: 1; height: 42px; background: var(--panel-2); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.trow {
  width: 100%; min-height: 56px; padding-top: 8px; padding-bottom: 8px; text-align: left; color: inherit;
  border: 0; border-bottom: 1px solid var(--line); background: transparent;
}
.trow:hover { background: var(--panel-2); }
.trow[aria-current="true"] { background: var(--select); }
.tcheck {
  justify-self: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2);
  display: grid; place-content: center;
}
.tcheck.head { border-color: var(--muted); }
.tcheck.head::after, .s-done .tcheck::after {
  content: ""; width: 5px; height: 9px; margin-top: -2px; border: solid var(--muted); border-width: 0 1.8px 1.8px 0; transform: rotate(45deg);
}
.s-doing .tcheck { border-color: var(--k-spec); background: conic-gradient(var(--k-spec) 0 50%, transparent 0); }
.s-blocked .tcheck { border-color: var(--soon); border-style: dashed; }
.s-done .tcheck { border-color: var(--k-decision); background: var(--k-decision); }
.s-done .tcheck::after { border-color: #fff; }
.ttitle { min-width: 0; display: grid; gap: 1px; }
.ttitle b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ttitle small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow.s-done .ttitle b { color: var(--muted); text-decoration: line-through; }
.trow.overdue .ttitle b { color: var(--late); }
.tpeople { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.person {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 2px 8px 2px 2px; border-radius: 6px;
  background: color-mix(in srgb, var(--k-spec) 12%, var(--panel)); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.person > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.person .avatar { margin: 0; border: 0; width: 20px; height: 20px; border-radius: 5px; }
.tdue { font-size: 12.5px; }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-2);
}
.s-doing .pill { color: var(--k-spec); border-color: color-mix(in srgb, var(--k-spec) 40%, transparent); }
.s-blocked .pill { color: var(--soon); border-color: color-mix(in srgb, var(--soon) 40%, transparent); }
.s-done .pill { color: var(--k-decision); border-color: color-mix(in srgb, var(--k-decision) 40%, transparent); }
.tid { justify-self: end; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tfoot { padding: 10px 14px; }
.tfoot:empty { display: none; }
.tfoot p { margin: 0; font-size: 12.5px; }
@media (max-width: 720px) {
  .tlist-wrap { padding: 0 16px 16px; }
  .tlist { margin-top: 12px; }
}

/* ---- calendar ---- */
.view-calendar .calendar-pane { display: flex; }
.calendar-pane .board-head { justify-content: flex-start; }
.calendar-pane .board-head .filter-toggle { margin-left: auto; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav h2 { margin: 0 4px; min-width: 96px; text-align: center; font-size: 15px; }
.cal-wrap { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px 24px; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 700px;
  border: 1px solid var(--line); border-radius: 12px; overflow: clip; background: var(--line); gap: 1px;
}
.cal-weekday { padding: 6px 8px; background: var(--panel-2); font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: center; }
.cal-weekday.sun, .cal-day.sun .cal-date { color: var(--late); }
.cal-weekday.sat, .cal-day.sat .cal-date { color: var(--k-spec); }
.cal-day { min-height: 108px; padding: 6px; background: var(--panel); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: var(--panel-2); }
.cal-day.other .cal-date { opacity: .45; }
.cal-date { align-self: flex-start; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 999px; }
.cal-day.today .cal-date { background: var(--ink); color: var(--panel) !important; }
.cal-task {
  display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 2px 6px; border-radius: 6px;
  border: 1px solid transparent; background: color-mix(in srgb, var(--muted) 10%, var(--panel)); color: var(--ink);
  font-size: 12px; text-align: left;
}
.cal-task:hover { border-color: var(--line-2); }
.cal-task[aria-current="true"] { border-color: var(--k-decision); box-shadow: 0 0 0 2px var(--focus); }
.cal-task .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-task .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.cal-task.s-doing { background: color-mix(in srgb, var(--k-spec) 12%, var(--panel)); }
.cal-task.s-doing .dot { background: var(--k-spec); }
.cal-task.s-blocked .dot { background: var(--soon); }
.cal-task.s-done { color: var(--muted); text-decoration: line-through; }
.cal-task.s-done .dot { background: var(--k-decision); }
.cal-task.overdue { background: color-mix(in srgb, var(--late) 12%, var(--panel)); color: var(--late); font-weight: 600; }
.cal-task.overdue .dot { background: var(--late); }
.cal-nodue { margin-top: 18px; }
.cal-nodue h2 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-nodue h2 .n { font-weight: 500; }
.cal-nodue-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.cal-nodue-list .cal-task { padding: 6px 10px; font-size: 12.5px; border-color: var(--line); background: var(--panel); }
@media (max-width: 720px) {
  .cal-wrap { padding: 12px 16px; }
  .calendar-pane .board-head { flex-wrap: wrap; }
  .calendar-pane .board-head p { order: 3; width: 100%; }
}

/* ---- 週 / 月 の切り替え ---- */
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--line); }
.seg button { border: 0; border-radius: 6px; padding: 3px 12px; background: transparent; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 60, 53, .12); }
.seg .n { margin-left: 4px; font-size: 11px; opacity: .65; font-variant-numeric: tabular-nums; }

/* ---- 週の帯 (Structured 風) ---- */
.week-strip {
  flex: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.ws-day {
  display: grid; justify-items: center; gap: 3px; padding: 6px 0 7px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink);
}
.ws-day:hover { background: var(--panel-2); }
.ws-day .w { font-size: 11px; font-weight: 600; color: var(--muted); }
.ws-day.sun .w { color: var(--late); }
.ws-day.sat .w { color: var(--k-spec); }
.ws-day .n {
  display: grid; place-content: center; width: 32px; height: 32px; border-radius: 50%;
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.ws-day.today .n { box-shadow: inset 0 0 0 2px var(--accent); }
.ws-day.selected .n { background: var(--ink); color: var(--panel); box-shadow: none; }
.ws-day .dots { display: flex; gap: 3px; height: 6px; }
.ws-day .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.ws-day .dots i.s-doing { background: var(--k-spec); }
.ws-day .dots i.s-blocked { background: var(--soon); }
.ws-day .dots i.s-done { background: var(--k-decision); }
.ws-day .dots i.overdue { background: var(--late); }

/* ---- 時系列 ---- */
.timeline { display: grid; gap: 6px; max-width: 820px; }
.tl-day { scroll-margin-top: 8px; }
.tl-day h3 {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 4px 6px;
  font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.tl-day.past h3 { color: var(--muted); }
.tl-day.late h3 { color: var(--late); }
.tl-day.selected h3 { color: var(--ink); }
.tl-day h3 .tag { padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; }
.tl-day h3 .n { margin-left: auto; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-empty { margin: 0 0 4px 126px; font-size: 12px; color: var(--muted); }
.tl-list { position: relative; display: grid; gap: 4px; }
/* カプセルをつなぐ縦の点線 */
.tl-list::before {
  content: ""; position: absolute; left: 88px; top: 18px; bottom: 18px; border-left: 2px dashed var(--line-2);
}
.tl-row {
  position: relative; display: grid; grid-template-columns: 52px 50px minmax(0, 1fr) 28px; align-items: center; gap: 12px;
  width: 100%; padding: 6px 8px 6px 0; border: 0; border-radius: 14px; background: transparent; color: inherit; text-align: left;
}
.tl-row:hover { background: var(--panel); }
.tl-row[aria-current="true"] { background: var(--select); }
.tl-when { justify-self: end; font-size: 11px; font-weight: 600; color: var(--muted); text-align: right; white-space: nowrap; }
.tl-icon {
  justify-self: center; display: grid; place-content: center; width: 44px; height: var(--cap, 54px); border-radius: 22px;
  font-size: 17px; font-weight: 700; z-index: 1;
  --c: var(--k-decision);
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--panel)); border: 2px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.tl-row.s-open .tl-icon { --c: #6c9a2a; }
.tl-row.s-doing .tl-icon { --c: var(--k-spec); }
.tl-row.s-blocked .tl-icon { --c: var(--soon); }
.tl-row.s-done .tl-icon { --c: var(--k-decision); background: var(--c); color: #fff; }
.tl-row.overdue .tl-icon { --c: var(--late); }
.tl-row.overdue .tl-when { color: var(--late); }
.tl-body { display: grid; gap: 2px; min-width: 0; }
.tl-body b { font-size: 14.5px; font-weight: 700; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tl-body small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row.s-done .tl-body b { color: var(--muted); text-decoration: line-through; }
.tl-row .tcheck { width: 24px; height: 24px; }
.view-calendar .cal-nodue { max-width: 820px; }
.tl-list.inbox::before { display: none; }

@media (max-width: 720px) {
  .week-strip { padding: 8px 10px; gap: 0; }
  .ws-day .n { width: 28px; height: 28px; font-size: 14px; }
  .tl-row { grid-template-columns: 40px 44px minmax(0, 1fr) 24px; gap: 8px; }
  .tl-icon { width: 38px; height: 48px; }
  .tl-list::before { left: 69px; }
  .tl-empty { margin-left: 100px; }
}


/* ---- 予定 (events) ---- */
/* カプセルはアクセントの黄緑で塗る。タスク (状態の色の枠) と見分けられるように */
.tl-row.ev .tl-icon { background: var(--fill, var(--c, var(--accent))); color: #fff; border: 0; font-size: 15px; }
.tl-row.ev.allday .tl-icon { background: color-mix(in srgb, var(--c, var(--accent)) 30%, var(--panel)); color: var(--c); }
.tl-when.timed { display: grid; justify-items: end; gap: 1px; color: var(--ink); }
.tl-when.timed b { font-size: 13px; font-variant-numeric: tabular-nums; }
.tl-when.timed small { font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
/* タスクの期限は予定より一段控えめに */
.tl-row.task .tl-icon { width: 36px; height: 36px; border-radius: 50%; font-size: 14px; }
.tl-row.task .tl-body b { font-size: 13.5px; font-weight: 600; }
.ws-day .dots i.ev { background: var(--fill, var(--c, var(--k-decision))); }
.cal-task.ev {
  color: var(--ink); font-weight: 600;
  background: var(--bar, linear-gradient(var(--c, var(--accent)), var(--c, var(--accent)))) left / 3px 100% no-repeat,
    color-mix(in srgb, var(--c, var(--accent)) 18%, var(--panel));
}
.cal-task.ev.allday {
  background: var(--bar, linear-gradient(var(--c, var(--accent)), var(--c, var(--accent)))) left / 3px 100% no-repeat,
    color-mix(in srgb, var(--c, var(--accent)) 32%, var(--panel));
}
.cal-task .tm { flex: none; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.event-box button { margin-right: 6px; }

/* ---- 1 日 (Structured のタイムライン) ---- */
/* 週の帯の丸を少し重ねる */
.ws-day .dots { gap: 0; height: 10px; align-items: center; }
.ws-day .dots i { width: 10px; height: 10px; margin-left: -3px; border: 1.5px solid var(--panel); box-sizing: content-box; }
.ws-day .dots i:first-child { margin-left: 0; }
.ws-day .dots b { margin-left: 2px; font-size: 9px; font-weight: 700; color: var(--muted); }
.day-view { max-width: 720px; }
.dt-head { display: flex; align-items: center; gap: 8px; margin: 6px 4px 12px; font-size: 15px; }
.dt-head .tag { padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; }
.dt-empty { margin: 8px 4px; color: var(--muted); font-size: 13px; }

/* 終日: 丸いアイコンを横に並べる */
.ad-strip { display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.ad-item {
  flex: none; display: grid; justify-items: center; gap: 6px; width: 76px; padding: 0; border: 0; background: transparent; color: inherit;
}
.ad-icon {
  display: grid; place-content: center; width: 52px; height: 52px; border-radius: 50%; font-size: 18px; font-weight: 700;
  color: #fff; background: var(--fill, var(--c, var(--muted)));
}
.ad-item.task .ad-icon { background: var(--panel-2); color: var(--ink-2); border: 2px solid var(--line-2); }
.ad-item.task.s-doing .ad-icon { color: var(--k-spec); border-color: var(--k-spec); }
.ad-item.task.s-blocked .ad-icon { color: var(--soon); border-color: var(--soon); }
.ad-item.task.s-done .ad-icon { color: #fff; background: var(--k-decision); border-color: var(--k-decision); }
.ad-item[aria-current="true"] .ad-icon { box-shadow: 0 0 0 3px var(--focus); }
.ad-label {
  max-width: 76px; font-size: 11.5px; font-weight: 600; line-height: 1.3; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ad-item.task.s-done .ad-label { color: var(--muted); text-decoration: line-through; }

/* 時刻のある予定: 縦の線でカプセルをつなぐ */
.dt-list { position: relative; display: grid; gap: 6px; padding: 4px 0 20px; }
.dt-list::before { content: ""; position: absolute; left: 95px; top: 20px; bottom: 30px; width: 3px; border-radius: 2px; background: var(--line-2); }
.dt-row {
  position: relative; display: grid; grid-template-columns: 52px 64px minmax(0, 1fr) 30px; align-items: stretch; column-gap: 12px;
  width: 100%; padding: 0 6px 0 0; border: 0; border-radius: 16px; background: transparent; color: inherit; text-align: left;
}
.dt-row:hover { background: var(--panel); }
.dt-row[aria-current="true"] { background: var(--select); }
.dt-times { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding: 4px 0; font-variant-numeric: tabular-nums; }
.dt-times b { font-size: 13px; }
.dt-times small { font-size: 12px; color: var(--muted); }
.dt-cap {
  z-index: 1; justify-self: center; display: grid; place-content: center; width: 56px; height: var(--h, 56px);
  border-radius: 28px; background: var(--fill, var(--c)); color: #fff; font-size: 19px; font-weight: 700;
}
.dt-body { display: grid; align-content: center; gap: 2px; min-width: 0; padding: 6px 0; }
.dt-body b { font-size: 15px; line-height: 1.4; }
.dt-body small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-check { align-self: center; justify-self: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--c); }
.dt-row.past .dt-check { background: var(--c); }
.dt-row.past .dt-check::after {
  content: ""; display: block; width: 6px; height: 11px; margin: 3px auto 0; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.dt-row.past .dt-cap { background: color-mix(in srgb, var(--c) 45%, var(--panel)); }
.dt-row.past .dt-body b { color: var(--muted); text-decoration: line-through; }
.dt-gap { margin-left: 140px; padding: 2px 0; font-size: 11.5px; color: var(--muted); }
.dt-now { position: relative; display: flex; align-items: center; margin: 2px 0 2px 46px; height: 18px; }
.dt-now::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid var(--late); }
.dt-now span { position: relative; padding: 0 6px; border-radius: 999px; background: var(--late); color: #fff; font-size: 11px; font-weight: 700; }
@media (max-width: 720px) {
  .dt-row { grid-template-columns: 44px 56px minmax(0, 1fr) 26px; column-gap: 8px; }
  .dt-cap { width: 48px; }
  .dt-list::before { left: 79px; }
  .dt-gap { margin-left: 116px; }
  .dt-now { margin-left: 38px; }
}

/* ---- スマホ幅: リストは 2 段の行、月のカレンダーは幅に収める ---- */
@media (max-width: 720px) {
  .tlist { min-width: 0; }
  .thead { display: none; }
  .trow {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    grid-template-areas: "check title due" "check people status";
    row-gap: 4px; column-gap: 10px; padding: 10px 12px;
  }
  .trow .tcheck { grid-area: check; align-self: start; margin-top: 2px; }
  .trow .ttitle { grid-area: title; }
  .trow .ttitle small { display: none; }
  .trow .tdue { grid-area: due; justify-self: end; font-size: 11.5px; }
  .trow .tdue .muted { display: none; }
  .trow .tpeople { grid-area: people; }
  .trow .tstatus { grid-area: status; justify-self: end; }
  .trow .tid { display: none; }

  .cal-grid { min-width: 0; }
  .cal-weekday { padding: 4px 0; font-size: 10.5px; }
  .cal-day { min-height: 64px; padding: 3px 2px; gap: 2px; }
  .cal-date { font-size: 11px; padding: 0 4px; }
  .cal-task { padding: 1px 3px; font-size: 10px; border-radius: 4px; gap: 3px; }
  .cal-task .tm { display: none; }
  .cal-task .dot { width: 5px; height: 5px; }
}

/* 詳細のタスク欄: 今の状態のボタンに状態の色を付ける */
.task-box.s-doing .status-seg button[aria-pressed="true"] { background: var(--k-spec); border-color: var(--k-spec); }
.task-box.s-blocked .status-seg button[aria-pressed="true"] { background: var(--soon); border-color: var(--soon); }
.task-box.s-done .status-seg button[aria-pressed="true"] { background: var(--k-decision); border-color: var(--k-decision); }

/* ---- リストの段 (パソコンでは表の中の見出し行) ---- */
.tgroup-head {
  display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 14px 6px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 700; color: var(--muted);
}
.tgroup-head .n { font-weight: 500; font-variant-numeric: tabular-nums; }
.g-overdue .tgroup-head { color: var(--late); }

/* スマホ用の担当チップとボードのタブは、パソコンでは出さない (左の絞り込みがある) */
.quick-who, .board-tabs { display: none; }

@media (max-width: 720px) {
  /* 担当チップ: 1 行で横にスクロール */
  .quick-who {
    flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none;
    border-bottom: 1px solid var(--line); background: var(--panel-2);
  }
  .quick-who::-webkit-scrollbar { display: none; }
  .quick-who .chip { flex: none; padding: 5px 12px; font-size: 13px; }
  .table-pane .filter-toggle, .board-pane .filter-toggle { display: none; }

  /* リスト: iPhone のリマインダーのように、段ごとに角の丸いカードにまとめる */
  .tlist { border: 0; background: transparent; overflow: visible; }
  .tgroup { margin-bottom: 16px; }
  .tgroup-head { padding: 0 6px 6px; background: none; border: 0; font-size: 13px; }
  .tgroup-rows { border-radius: 14px; background: var(--panel); border: 1px solid var(--line); overflow: clip; }
  .trow { min-height: 60px; padding: 12px 14px; column-gap: 12px; }
  .tgroup-rows .trow:last-child { border-bottom: 0; }
  .trow .tcheck { width: 24px; height: 24px; }
  .trow .ttitle b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 15px; line-height: 1.4; }
  .trow .tpeople { gap: 4px; }
  .trow .person { padding: 1px 6px 1px 1px; font-size: 12px; }
  .trow .person .avatar { width: 18px; height: 18px; font-size: 9.5px; }
  .tfoot { padding: 4px 6px; }

  /* ボード: 上のタブで状態を選び、1 列ずつ画面いっぱいに見せる (スワイプでも切り替わる) */
  .board-tabs {
    flex: none; display: flex; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  }
  .board-tabs button {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 4px;
    border: 0; border-radius: 9px; background: transparent; font-size: 13px; font-weight: 600; color: var(--muted);
  }
  .board-tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
  .board-tabs .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
  .board-tabs .c-doing .dot { background: var(--k-spec); }
  .board-tabs .c-blocked .dot { background: var(--soon); }
  .board-tabs .c-done .dot { background: var(--k-decision); }
  .board-tabs .n { font-size: 11.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
  .board {
    grid-template-columns: repeat(4, calc(100vw - 32px)); gap: 16px; padding: 12px 16px 16px;
    scroll-snap-type: x mandatory; scroll-padding-inline: 16px; scrollbar-width: none;
  }
  .board::-webkit-scrollbar { display: none; }
  .column { scroll-snap-align: start; background: transparent; }
  .column h2 { display: none; }
  .column-body { padding: 0; gap: 10px; }
  .card { padding: 14px 16px; border-radius: 14px; }
  .card h3 { font-size: 15px; }
}

/* 日の表示で予定が無い日に出す「次の予定」 */
.dt-next {
  display: grid; gap: 2px; width: 100%; max-width: 420px; margin: 4px 0 0; padding: 12px 14px; text-align: left; color: inherit;
  border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); border-radius: 12px; background: var(--panel);
}
.dt-next:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.dt-next .lbl { font-size: 11px; font-weight: 700; color: var(--muted); }
.dt-next b { font-size: 13px; font-variant-numeric: tabular-nums; }
.dt-next span:last-child { font-size: 14px; font-weight: 600; }

.cal-error { margin-top: 12px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--late) 40%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--late) 8%, var(--panel)); }
.cal-error p { margin: 0 0 8px; font-size: 13px; overflow-wrap: anywhere; }

/* 日の表示: タスクの欄 */
.dt-tasks { margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dt-tasks h4 { display: flex; align-items: center; gap: 6px; margin: 0 4px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.dt-tasks h4 .n { font-weight: 500; font-variant-numeric: tabular-nums; }
.dt-task-list { display: grid; gap: 2px; }

/* iPhone は 16px 未満の入力欄を触ると拡大し、そのまま戻らない。スマホ幅では入力欄を 16px にする */
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; }
  .search input { padding-top: 8px; padding-bottom: 8px; }
}

/* ---- cards (名刺) ---- */
.view-cards .cards-pane { display: flex; }
.cards-head {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line);
}
.cards-head input[type="search"] {
  flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--panel-2); outline: none;
}
.cards-head input[type="search"]:focus { border-color: var(--k-decision); box-shadow: 0 0 0 3px var(--focus); background: var(--panel); }
.cards-bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
}
.cards-bar p { margin: 0; font-size: 12px; color: var(--muted); }
.cards-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px 24px; }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.crow {
  display: grid; gap: 4px; width: 100%; text-align: left; padding: 10px 12px; color: inherit;
  border: 1px solid transparent; border-radius: 10px; background: transparent;
}
.crow:hover { background: var(--panel); border-color: var(--line); }
.crow[aria-current="true"] { background: var(--select); border-color: var(--line-2); }
.crow-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.crow-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow.archived .crow-name { color: var(--muted); text-decoration: line-through; }
.crow-flag { flex: none; font-size: 11px; color: var(--k-todo); }
.crow-met { margin-left: auto; flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.crow-sub { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.ctag { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.company-group { list-style: none; }
.company-group h3 { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; padding: 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.company-group h3 .n { font-weight: 500; font-variant-numeric: tabular-nums; }
.card-sublist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

/* 名刺の詳細 */
.card-images { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.card-image { margin: 0; display: grid; gap: 4px; max-width: 100%; }
.card-image img {
  display: block; max-width: min(340px, 100%); max-height: 220px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel-2); cursor: zoom-in;
}
.card-image figcaption { font-size: 11px; color: var(--muted); text-align: center; }

/* 記憶に添付した画像 */
.memory-file { margin: 18px 0 0; display: grid; gap: 4px; max-width: 100%; }
.memory-file img {
  display: block; max-width: 100%; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel-2);
}
.memory-file figcaption { font-size: 11px; color: var(--muted); }
.memory-file-actions { display: flex; gap: 6px; margin-top: 2px; }

.card-archived-note { margin: 0 0 14px; padding: 8px 12px; border-radius: 9px; background: color-mix(in srgb, var(--k-todo) 12%, var(--panel)); color: var(--k-todo); font-size: 13px; font-weight: 600; }
/* 名刺の項目: ラベル | 値 の表。外枠 1px、行ごとに区切り線 (最後の行は線なし) */
.card-box { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.card-box dl { display: grid; grid-template-columns: 6em minmax(0, 1fr); margin: 0; }
.card-box dl > div { display: contents; }
.card-box dt, .card-box dd { display: flex; align-items: center; min-width: 0; border-bottom: 1px solid var(--line); }
.card-box dt { padding: 9px 12px; background: var(--panel-2); border-right: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.card-box dd { margin: 0; padding: 9px 12px; font-size: 14px; font-weight: 400; overflow-wrap: anywhere; }
.card-box dl > div:last-child dt, .card-box dl > div:last-child dd { border-bottom: 0; }
.card-box dd.name { font-weight: 600; }
.card-box dd a { color: var(--k-spec); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--k-spec) 40%, transparent); overflow-wrap: anywhere; }
.card-memo { margin-bottom: 18px; }
.card-archive { margin: 22px 0 0; }
.card-meetings { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.card-meetings h2 { margin: 0 0 10px; font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.meeting-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.meeting { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.meeting-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.meeting-head b { font-size: 13px; }
.meeting-head .spacer { flex: 1; }
.meeting-place { font-size: 12px; color: var(--ink-2); }
.meeting-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 12.5px; }
.meeting-links a { color: var(--k-spec); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--k-spec) 40%, transparent); }
.meeting-note { margin: 6px 0 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-links { margin-top: 26px; }
.card-links li a { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.card-links li a:hover { background: var(--panel-2); }
.card-links .rt { font-size: 13px; font-weight: 600; }

/* 名刺の登録・編集フォーム */
.card-form { display: grid; gap: 16px; margin-top: 8px; }
.card-photos { display: grid; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2); }

/* 写真のタイル (表・裏)。名刺の比率 (91:55) で大きく見せる */
.card-photo-tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .card-photo-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.photo-tile { position: relative; min-width: 0; }
.photo-tile-frame { position: relative; }
.photo-tile-body {
  position: relative; display: block; width: 100%; aspect-ratio: 91 / 55; padding: 0; overflow: hidden;
  border: 1px dashed var(--line-2); border-radius: 12px; background: var(--panel-2); color: var(--muted); cursor: pointer;
}
.photo-tile-body.has-image { border-style: solid; border-color: var(--line); }
.photo-tile-body img { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--panel-2); }
.photo-empty { display: grid; place-content: center; height: 100%; padding: 8px; font-size: 13px; font-weight: 600; }
.photo-tag {
  position: absolute; top: 6px; left: 6px; z-index: 2; padding: 1px 8px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line-2); font-size: 11px; font-weight: 700; color: var(--ink-2);
}
.photo-tile-overlay {
  position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 45%, transparent); color: var(--panel); font-size: 13px; font-weight: 700;
}
.photo-tile-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.photo-ocr-actions { margin-top: 10px; }
.linkish { border: 0; background: transparent; padding: 0; color: var(--k-spec); font: inherit; font-size: 11.5px; text-decoration: underline; cursor: pointer; }
/* ファイルの input は見えなくする (display:none は iOS で効かないことがある)。label で包んで隠す */
.photo-inputs { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; opacity: 0; }

/* 名刺の編集: 詳細と同じ表 (.card-box) のまま、値のセルを入力欄にする */
.card-form-box dd { padding: 0; }
.card-form-box dd > input, .card-form-box dd > select, .card-form-box dd > textarea {
  width: 100%; margin: 0; padding: 9px 12px; border: 0; border-radius: 0; background: transparent;
  color: inherit; font-family: inherit; font-size: 14px; outline: none;
}
.card-form-box dd > textarea { display: block; resize: vertical; line-height: 1.6; }
.card-form-box dd > input::placeholder, .card-form-box dd > textarea::placeholder { color: var(--muted); opacity: .55; }
.card-form-box dl > div:focus-within dd { background: color-mix(in srgb, var(--k-decision) 10%, transparent); box-shadow: inset 0 0 0 2px var(--focus); }
.card-form-box dt .req { margin-left: 4px; font-size: 10px; font-weight: 500; color: var(--k-todo); }

/* 編集の写真差し替えは控えめに折りたたむ */
.card-photo-details { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.card-photo-details > summary { padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.card-photo-details[open] > summary { border-bottom: 1px solid var(--line); }
.card-photo-inner { display: grid; gap: 12px; padding: 12px 14px; }

/* 「裏も撮りますか？」の帯 (タッチ端末の新規登録だけ) */
.card-nextstep {
  display: grid; gap: 8px; padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--k-decision) 40%, transparent); border-radius: 12px;
  background: color-mix(in srgb, var(--k-decision) 10%, var(--panel));
}
.card-nextstep .nextstep-title { margin: 0; font-size: 14px; font-weight: 700; }
.card-nextstep .nextstep-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-nextstep .nextstep-actions button { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.field { display: grid; gap: 3px; min-width: 0; }
.field > span { font-size: 11px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--k-decision); box-shadow: 0 0 0 3px var(--focus); }
.field-wide { grid-column: 1 / -1; }
.card-form .form-actions { justify-content: flex-end; }
.form-actions { display: flex; gap: 8px; }
.card-dup-box { padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--soon) 40%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--soon) 8%, var(--panel)); display: grid; gap: 10px; }
.card-dup-box .card-dup-title { margin: 0; font-size: 13px; font-weight: 700; }
.card-dup-box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card-dup-box li.dup-item { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.card-dup-box li.dup-item > a { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; color: var(--ink); text-decoration: none; }
.card-dup-box li.dup-item > a:hover { text-decoration: underline; }
.card-dup-box .dup-archived { padding: 0 5px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 11px; font-weight: 500; color: var(--muted); }
.card-dup-box .dup-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); }
.card-dup-box .dup-match { margin: 0; font-size: 11px; font-weight: 500; color: var(--muted); }
.card-dup-box .dup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-dup-box .dup-actions .primary { margin-left: auto; }
.card-dup-box .card-dup-save { justify-self: end; }
.card-dup-diff { width: 100%; border-collapse: collapse; font-size: 12px; }
.card-dup-diff th, .card-dup-diff td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.card-dup-diff thead th { border-bottom: 1px solid var(--line-2); font-size: 11px; color: var(--muted); }
.card-dup-diff .dup-old { color: var(--muted); }
.card-dup-diff .dup-new { font-weight: 700; }
.card-dup-box .dup-check { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.meeting-form { display: grid; gap: 10px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2); }

/* 名刺の画像を大きく見る */
.image-dialog { border: 0; padding: 10px; max-width: 96vw; max-height: 96vh; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); }
.image-dialog::backdrop { background: rgba(10, 20, 16, .7); }
.image-dialog img { display: block; max-width: 92vw; max-height: 82vh; margin: 0 auto 8px; }
.image-dialog button { display: block; margin: 0 0 0 auto; }

@media (max-width: 720px) {
  .cards-head { flex-wrap: wrap; padding: 10px 16px; }
  .cards-head input[type="search"] { flex: 1 1 100%; }
  .cards-bar { padding: 10px 16px; }
  .cards-body { padding: 8px 10px 24px; }
  .field-grid { grid-template-columns: 1fr; }
  .detail-bar { flex-wrap: wrap; }
}

/* 名刺の入力欄はスマホでも 16px にする。iPhone は 16px 未満の入力欄にフォーカスすると勝手に拡大するため。
   名刺フォーム (.card-form-box) と、その詳細の中の会った履歴フォーム (.field) が対象 */
@media (max-width: 720px) {
  .card-form-box dd > input, .card-form-box dd > select, .card-form-box dd > textarea { font-size: 16px; }
  .card-detail .field input, .card-detail .field select, .card-detail .field textarea { font-size: 16px; }
}

/* ---- 経過 (memory_logs) ---- */
.primary.small { padding: 4px 12px; font-size: 12px; }

/* 一覧の「経過 N」の印。「最終更新」の日時は今までどおり */
.log-badge { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

/* 検索結果: 経過で当たった記憶の行の、抜粋の下の 1 行 */
.memory .log-hit {
  margin: 3px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 詳細の「経過」欄 */
.log-section { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); }
.log-section h2 { margin: 0 0 10px; font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.log-form { display: grid; gap: 6px; margin-bottom: 18px; }
.log-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--panel-2); color: inherit; font: inherit; font-size: 14px; line-height: 1.6;
  resize: vertical; outline: none;
}
.log-input:focus { border-color: var(--k-decision); box-shadow: 0 0 0 3px var(--focus); background: var(--panel); }
.log-actions { display: flex; align-items: center; gap: 10px; }
.log-error { flex: 1; margin: 0 !important; }

/* 時系列: git のログのように、左に縦線と点、右に内容 */
.log-list { display: grid; gap: 0; }
.log-entry { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; }
.log-entry:last-child { padding-bottom: 0; }
.log-rail { position: relative; }
.log-rail::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--line-2); }
.log-entry:first-child .log-rail::before { top: 8px; }
.log-entry:last-child .log-rail::before { bottom: auto; height: 8px; }
.log-dot {
  position: absolute; left: 3px; top: 6px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--k-decision); box-shadow: 0 0 0 2px var(--panel);
}
.log-change .log-dot { background: var(--muted); }
.log-main { min-width: 0; }
.log-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.log-time { font-variant-numeric: tabular-nums; }
.log-by { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-weight: 600; }
.log-by .avatar { margin: 0; }
.log-body { margin: 3px 0 0; font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-line { margin: 2px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--muted); }

/* スマホでも経過の入力欄は 16px。上の .log-input の 14px に負けないよう、後ろで上書きする */
@media (max-width: 720px) {
  .log-input { font-size: 16px; }
  .log-entry { grid-template-columns: 14px minmax(0, 1fr); gap: 10px; }
  .log-rail::before { left: 6px; }
  .log-dot { left: 2px; }
}
