/*
  Elmtable の見た目。人が選んだ「A：展示ケースの棚」（2026-10-25）を、上質なサービスの実測
  （tmp/project-hub/research_notes/visual_craft.md §9）で詰めたもの。言葉は promo-studio の一覧と同じ。

  決まり（数えて超えたら、理由を書くか消す）
  - 字は 4 つ：12（添え）・14（本文・題）・16（節）・20（ページの名前・数）。太さは 400・500・600（700 は使わない）
  - 余白は 7 つ：4・8・12・16・24・32・48
  - 角は 3 つ：板 14・押すもの 10・札 999
  - 影は 2 つ：板（輪＋ごく薄い影）・浮く物（ホバー・シート・ポップ）。板の中は罫と余白だけ
  - 強調は青 1 色。青は「あなたの番」「選んでいる状態」「押せる主な物」だけ。状態は灰の形で示す
  - 見出しは中央。本文・一覧・表・フォームは中央の列の中で左
  - 明るい地だけ
*/
:root {
  --room: radial-gradient(120% 75% at 50% -12%, #ffffff 0%, #f1f2f4 48%, #e7e9ec 100%);
  --room-base: #e7e9ec;
  --paper: #ffffff;
  --paper-2: #fafbfc;
  --ink: #15171b;
  --dim: #545a64;
  --faint: #676b72;
  --line: rgb(30 40 70 / 9%);
  --line-2: rgb(30 40 70 / 16%);
  --fill: rgb(20 28 45 / 4.5%);
  --fill-2: rgb(20 28 45 / 8%);
  --accent: #2f64e6;
  --accent-ink: #ffffff;
  --accent-soft: rgb(47 100 230 / 9%);
  --accent-line: rgb(47 100 230 / 35%);
  --warn: #8a5a00;
  --warn-soft: rgb(183 116 0 / 11%);
  --danger: #b4312f;
  --danger-soft: rgb(193 54 59 / 9%);
  --good: #1f6f47;
  --good-soft: rgb(31 122 77 / 10%);

  /* 影は 2 つ */
  --plate: 0 0 0 1px rgb(30 40 70 / 8%), 0 1px 2px rgb(20 28 45 / 5%);
  --lift: 0 0 0 1px rgb(30 40 70 / 12%), 0 4px 12px -4px rgb(20 28 45 / 12%), 0 18px 40px -24px rgb(20 28 45 / 22%);

  --glass: rgb(255 255 255 / 80%);
  --blur: saturate(180%) blur(20px);

  /* 字 */
  --fs-s: 12px;
  --fs-m: 14px;
  --fs-l: 16px;
  --fs-xl: 20px;
  /* 余白 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  /* 角 */
  --r-plate: 14px;
  --r: 10px;

  --bar: 56px;
  --hit: 40px;
  --col: 46rem;
  --col-wide: 72rem;
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (pointer: coarse) {
  :root { --hit: 44px; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgb(248 249 250 / 97%); }
}
@media (prefers-contrast: more) {
  :root { --glass: #f7f8f9; --line: rgb(30 40 70 / 20%); --faint: #50555d; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--room-base); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--room) no-repeat, var(--room-base);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 var(--fs-m) / 1.7 var(--font);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; line-height: 1.4; }
p { margin: 0; text-wrap: pretty; }
button { font: inherit; letter-spacing: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-s); line-height: 1.5; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.link { color: var(--accent); }
.center-text { text-align: center; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- ヘッダー（すりガラス） ---------------------------------------------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(var(--bar) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(var(--s4), env(safe-area-inset-right, 0px)) 0 max(var(--s4), env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s3);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: inset 0 -1px 0 var(--line);
}
.bar-l, .bar-r { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.bar-r { justify-content: flex-end; }
.mark { display: inline-flex; align-items: center; gap: var(--s2); height: var(--hit); padding: 0 var(--s2); margin-left: calc(-1 * var(--s2)); border-radius: var(--r); font-weight: 600; letter-spacing: 0.01em; }
.mark svg { width: 20px; height: 20px; color: var(--accent); }
.mark:hover { background: var(--fill); }
.nav { display: flex; gap: var(--s1); }
.nav a { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 var(--s3); border-radius: var(--r); color: var(--dim); }
.nav a:hover { color: var(--ink); background: var(--fill); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
.back { display: inline-flex; align-items: center; gap: 6px; height: var(--hit); padding: 0 var(--s2); margin-left: calc(-1 * var(--s2)); border-radius: var(--r); color: var(--dim); min-width: 0; }
.back:hover { color: var(--ink); background: var(--fill); }
.back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 狭い画面：上のナビは隠し、下のタブ */
.tabbar { display: none; }
@media (max-width: 760px) {
  .bar { grid-template-columns: minmax(0, 1fr) auto; }
  .bar .nav, .bar .bar-mid { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: var(--s1) var(--s2) calc(var(--s1) + env(safe-area-inset-bottom, 0px));
    background: var(--glass);
    -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    box-shadow: inset 0 1px 0 var(--line);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; color: var(--faint); font-size: 11px; letter-spacing: 0.04em;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .tabbar .dot { position: absolute; top: 6px; left: calc(50% + 7px); }
  body.has-tabbar main { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* ---- 押すもの ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--hit); padding: 0 var(--s4); border: 0; border-radius: var(--r);
  background: var(--paper); color: var(--ink); box-shadow: var(--plate);
  font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
.btn:hover { box-shadow: var(--lift); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgb(20 28 45 / 12%); }
.btn.primary:hover { background: #2556d1; }
.btn.quiet { background: transparent; box-shadow: none; color: var(--dim); }
.btn.quiet:hover { background: var(--fill); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 var(--s3); font-size: var(--fs-s); }
.btn.icon { padding: 0; width: var(--hit); }
.btn.wide { width: 100%; min-height: 48px; font-size: var(--fs-m); }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: 0.45; cursor: default; box-shadow: var(--plate); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.actions.center { justify-content: center; }
.actions.end { justify-content: flex-end; }
.actions.between { justify-content: space-between; }

/* 小さな札（期限・社内・状態の言葉） */
.tag { display: inline-flex; align-items: center; gap: var(--s1); height: 22px; padding: 0 var(--s2); border-radius: 999px; background: var(--fill); color: var(--dim); font-size: var(--fs-s); line-height: 1; white-space: nowrap; }
.tag.blue { background: var(--accent-soft); color: var(--accent); }
.tag.amber { background: var(--warn-soft); color: var(--warn); }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.green { background: var(--good-soft); color: var(--good); }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 1; letter-spacing: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* 状態の形（灰）：始まる前＝点線の円・進行中＝半分・公開後＝満ちた円・終了＝チェック */
.st { width: 16px; height: 16px; flex: none; color: var(--faint); }
.st.mine { color: var(--accent); }

.avatar { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--fill-2); color: var(--dim); font-size: 10px; font-weight: 600; flex: none; letter-spacing: 0; line-height: 1; }
.avatar.me { background: var(--accent); color: #fff; }
.avatar.l { width: 32px; height: 32px; font-size: 12px; }
.faces { display: inline-flex; align-items: center; }
.faces .avatar { width: 28px; height: 28px; font-size: 11px; box-shadow: 0 0 0 2px var(--paper); }
.faces .avatar + .avatar { margin-left: -6px; }
.faces:hover .avatar { box-shadow: 0 0 0 2px var(--paper); }

/* ---- ページの骨 ------------------------------------------------------------- */
main { padding: var(--s6) var(--s4) var(--s7); }
@media (min-width: 761px) { main { padding-inline: var(--s5); } }
.col { max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: var(--s6); }
.col.wide { max-width: var(--col-wide); }
.col.narrow { max-width: 36rem; }
.head { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; }
.head h1 { font-size: var(--fs-xl); letter-spacing: 0.01em; }
.head .sub { color: var(--dim); }
.section { display: flex; flex-direction: column; gap: var(--s3); }
.section > h2 { font-size: var(--fs-l); text-align: center; letter-spacing: 0.02em; }
.section > .hint { text-align: center; color: var(--faint); font-size: var(--fs-s); margin-top: calc(-1 * var(--s1)); }

/* 板（中身の層）。中は罫と余白だけ */
.plate { background: var(--paper); border-radius: var(--r-plate); box-shadow: var(--plate); overflow: hidden; min-width: 0; }
.plate.pad { padding: var(--s5); }
@media (max-width: 520px) { .plate.pad { padding: var(--s4); } }

/* 一覧の行（1 行 44・2 行 60） */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li > .row::before, .rows > li + li > .rowx::before { content: ""; position: absolute; top: 0; left: var(--row-indent, var(--s4)); right: 0; border-top: 1px solid var(--line); }
.row {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); row-gap: 2px; align-items: center;
  min-height: 60px; padding: 10px var(--s4); --row-indent: var(--s4);
}
.row.lead, .row.lead-date, .row.lead-face, .row.lead-kind { grid-template-columns: var(--lead) minmax(0, 1fr) auto; --row-indent: calc(var(--s4) + var(--lead) + var(--s3)); }
.row.lead { --lead: 16px; }
.row.lead-date { --lead: 40px; }
.row.lead-face { --lead: 32px; }
.row.lead-kind { --lead: 2.6em; }
.row.lead-kind > .ld { justify-content: flex-start; align-self: start; padding-top: 1px; }
a.row:hover { background: var(--paper-2); }
.row > .ld { grid-column: 1; grid-row: 1 / span 2; align-self: center; display: flex; justify-content: center; }
.row:not(.lead):not(.lead-date):not(.lead-face):not(.lead-kind) > .ld { display: none; }
.row .t { grid-column: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
.row .t.wrap { white-space: normal; overflow-wrap: anywhere; }
.row .m { grid-column: 1; color: var(--faint); font-size: var(--fs-s); line-height: 1.5; display: flex; flex-wrap: wrap; column-gap: var(--s3); min-width: 0; }
.row .r { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; color: var(--faint); font-size: var(--fs-s); }
:is(.row.lead, .row.lead-date, .row.lead-face, .row.lead-kind) > :is(.t, .m) { grid-column: 2; }
:is(.row.lead, .row.lead-date, .row.lead-face, .row.lead-kind) > .r { grid-column: 3; }
.row .kind { color: var(--accent); font-size: var(--fs-s); font-weight: 500; }
.date-n { font-size: var(--fs-m); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.2; text-align: center; }
.date-n small { display: block; font-size: 11px; font-weight: 400; color: var(--faint); }
.empty { padding: var(--s5) var(--s4); text-align: center; color: var(--faint); }

/* 3 つの数 */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.tile { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 68px; padding: var(--s3) var(--s4); border-radius: var(--r-plate); background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
a.tile:hover { box-shadow: var(--lift); }
.tile .k { font-size: var(--fs-s); color: var(--faint); line-height: 1.4; }
.tile .v { font-size: var(--fs-xl); font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tile.mine .v { color: var(--accent); }
@media (max-width: 400px) { .tiles { gap: var(--s2); } .tile { padding: var(--s3); } }

/* お金の 1 行 */
.money-line { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s2) var(--s5); color: var(--dim); }
.money-line b { color: var(--ink); font-size: var(--fs-l); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: var(--s2); }
a.money-line:hover b { color: var(--accent); }

/* 数の並び（お金のページ） */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.figures > div { padding: var(--s4); display: flex; flex-direction: column; gap: 2px; }
.figures > div + div { box-shadow: inset 1px 0 0 var(--line); }
.figures .k { font-size: var(--fs-s); color: var(--faint); }
.figures .v { font-size: var(--fs-xl); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
@media (max-width: 640px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .figures > div:nth-child(3) { box-shadow: inset 0 1px 0 var(--line); }
  .figures > div:nth-child(4) { box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line); }
}

/* ---- 案件のカード（展示ケース） -------------------------------------------- */
.filters { display: flex; justify-content: center; }
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 2px; border-radius: 12px; background: var(--fill); box-shadow: inset 0 0 0 1px var(--line); }
.seg::-webkit-scrollbar { display: none; }
.seg a { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--s3); border-radius: 9px; color: var(--dim); line-height: 1; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(20 28 45 / 6%); }
.seg .n { color: var(--faint); font-size: var(--fs-s); font-variant-numeric: tabular-nums; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s4); }
@media (max-width: 640px) { .cards { gap: var(--s3); } }
.card {
  display: flex; flex-direction: column; min-width: 0; border-radius: var(--r-plate); background: var(--paper); box-shadow: var(--plate); overflow: hidden;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.card:hover { box-shadow: var(--lift); transform: translateY(-1px); }
.card .shot { position: relative; aspect-ratio: 16 / 10; background: var(--paper-2); overflow: hidden; }
.card .shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card .shot::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 -1px 0 var(--line); pointer-events: none; }
.card .in { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s4); flex: 1; }
.card .meta { display: flex; align-items: center; gap: var(--s2); color: var(--faint); font-size: var(--fs-s); line-height: 1.5; }
.card .meta .due { margin-left: auto; font-variant-numeric: tabular-nums; }
.card h3 { font-size: var(--fs-m); font-weight: 600; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 3em; }
.card .ball { display: flex; align-items: center; gap: var(--s2); margin-top: auto; padding-top: var(--s3); box-shadow: inset 0 1px 0 var(--line); color: var(--dim); font-size: var(--fs-s); }
.card .ball .w { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }
.card.mine .ball { color: var(--accent); font-weight: 500; }

/* ---- 案件のシート ------------------------------------------------------------ */
.sheet { max-width: 56rem; margin: 0 auto; width: 100%; background: var(--paper); border-radius: 18px; box-shadow: var(--plate), 0 24px 60px -36px rgb(20 28 45 / 28%); }
.sheet-top { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s5) var(--s5) var(--s4); text-align: center; }
.sheet-top .over { color: var(--faint); font-size: var(--fs-s); }
.sheet-top h1 { font-size: var(--fs-xl); letter-spacing: 0.01em; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); box-shadow: inset 0 1px 0 var(--line), inset 0 -1px 0 var(--line); }
.facts > div { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); min-width: 0; }
.facts > div + div { box-shadow: inset 1px 0 0 var(--line); }
.facts .k { font-size: var(--fs-s); color: var(--faint); }
.facts .v { display: flex; align-items: center; gap: 6px; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts .v.mine { color: var(--accent); }
@media (max-width: 640px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .facts > div:nth-child(3) { box-shadow: inset 0 1px 0 var(--line); }
  .facts > div:nth-child(4) { box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line); }
}
.utabs {
  position: sticky; top: calc(var(--bar) + env(safe-area-inset-top, 0px)); z-index: 10;
  display: flex; justify-content: center; gap: var(--s5); padding: 0 var(--s4); overflow-x: auto; scrollbar-width: none;
  background: rgb(255 255 255 / 92%); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: inset 0 -1px 0 var(--line);
}
.utabs::-webkit-scrollbar { display: none; }
.utabs a { flex: none; position: relative; display: inline-flex; align-items: center; gap: 6px; height: 44px; color: var(--dim); }
.utabs a:hover { color: var(--ink); }
.utabs a[aria-current="true"] { color: var(--ink); }
.utabs a[aria-current="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--accent); }
@media (max-width: 640px) { .utabs { justify-content: flex-start; gap: var(--s4); } .sheet { border-radius: var(--r-plate); } .sheet-top { padding: var(--s4); } }
.sheet-body { display: flex; flex-direction: column; }
.part { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); }
.part + .part { box-shadow: inset 0 1px 0 var(--line); }
.part > h2 { position: relative; font-size: var(--fs-m); font-weight: 600; letter-spacing: 0.02em; text-align: center; min-height: 32px; display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.part > h2 .more { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
@media (max-width: 520px) { .part > h2 { flex-direction: column; } .part > h2 .more { position: static; transform: none; } }
@media (max-width: 520px) { .part { padding: var(--s4); } }
/* シートの中の一覧は、板の縁を持たない */
.part .rows { margin: 0 calc(-1 * var(--s5)); }
.part .row { padding-inline: var(--s5); --row-indent: var(--s5); }
.part :is(.row.lead, .row.lead-date, .row.lead-face, .row.lead-kind) { --row-indent: calc(var(--s5) + var(--lead) + var(--s3)); }
@media (max-width: 520px) { .part .rows { margin: 0 calc(-1 * var(--s4)); } .part .row { padding-inline: var(--s4); } }

/* 依頼の中身（ラベルと値） */
.kv { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); margin: 0; }
.kv > dt, .kv > dd { margin: 0; padding: 10px 0; }
.kv > dt { color: var(--faint); font-size: var(--fs-s); line-height: 1.7; padding-right: var(--s3); }
.kv > dt:not(:first-of-type), .kv > dt:not(:first-of-type) + dd { box-shadow: inset 0 1px 0 var(--line); }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } .kv > dd { padding-top: 0; box-shadow: none !important; } }

/* 開く入力欄（＋ 足す） */
details.add > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--accent); font-size: var(--fs-s); font-weight: 500; }
details.add > summary::-webkit-details-marker { display: none; }
details.add > summary::before { content: "＋"; }
details.add[open] > summary::before { content: "－"; }
details.add[open] > summary { margin-bottom: var(--s3); }
details.add > .form { padding: var(--s4); border-radius: var(--r); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }

/* ---- やりとり ----------------------------------------------------------------- */
.thread { display: flex; flex-direction: column; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--s3); row-gap: 2px; padding: var(--s4) 0; scroll-margin-top: 120px; }
.msg + .msg { box-shadow: inset 0 1px 0 var(--line); }
.msg .avatar { grid-row: 1 / span 2; }
.msg .who { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--s2); line-height: 1.5; }
.msg .who b { font-weight: 600; }
.msg .who .small { color: var(--faint); }
.msg .body { min-width: 0; }
.msg.internal .body { padding: var(--s2) var(--s3); border-radius: var(--r); background: var(--warn-soft); }
.msg.draft .body { padding: var(--s2) var(--s3); border-radius: var(--r); background: var(--accent-soft); }
.msg:target { background: linear-gradient(var(--accent-soft), var(--accent-soft)) padding-box; }
.composer { display: flex; flex-direction: column; gap: var(--s3); }
/* 板の中に直に置いた入力（設定のトークン・ユーザー管理の招待など）：板の縁から離し、上の一覧とは線で分ける */
.plate > .composer { padding: var(--s4) var(--s5) var(--s5); }
.plate > .rows + .composer, .plate > .composer + .rows, .plate > .composer + .composer { border-top: 1px solid var(--line); }
@media (max-width: 520px) { .plate > .composer { padding: var(--s4); } }

/* Markdown の中身 */
.md { overflow-wrap: anywhere; line-height: 1.75; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md .md-table { margin: 0 0 var(--s3); }
.md h1, .md h2, .md h3, .md h4 { font-size: var(--fs-m); font-weight: 600; margin: var(--s4) 0 var(--s1); text-align: left; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 2px; }
.md strong { font-weight: 600; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--accent-line); }
.md code { font-family: var(--mono); font-size: 0.9em; background: var(--fill); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--fill); padding: var(--s3) var(--s4); border-radius: var(--r); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin-left: 0; padding-left: var(--s3); box-shadow: inset 3px 0 0 var(--line-2); color: var(--dim); }
.md .md-table { overflow-x: auto; }
.md table { border-collapse: collapse; font-size: var(--fs-s); }
.md th, .md td { padding: 6px 10px; text-align: left; vertical-align: top; box-shadow: inset 0 -1px 0 var(--line); }
.md th { font-weight: 600; color: var(--dim); }
.md hr { border: 0; height: 1px; background: var(--line); margin: var(--s4) 0; }

/* ---- 問い --------------------------------------------------------------------- */
.q { display: flex; flex-direction: column; gap: var(--s3); }
.q .qh { display: flex; flex-direction: column; gap: var(--s1); }
.q h3 { font-size: var(--fs-l); font-weight: 600; }
.q .who { color: var(--faint); font-size: var(--fs-s); }
.opts { display: grid; gap: var(--s2); }
.opt {
  position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: var(--s3); row-gap: 2px; align-items: center;
  min-height: 56px; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2);
  cursor: pointer; transition: box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
.opt:hover { box-shadow: inset 0 0 0 1px rgb(30 40 70 / 28%); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .mark-o { grid-row: 1 / span 2; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-2); background: var(--paper); }
.opt.multi .mark-o { border-radius: 5px; }
.opt .lab { font-weight: 500; line-height: 1.5; }
.opt .key { color: var(--faint); font-weight: 500; margin-right: var(--s2); font-variant-numeric: tabular-nums; }
.opt .desc { grid-column: 2; color: var(--dim); font-size: var(--fs-s); line-height: 1.5; }
.opt .rec { grid-column: 3; grid-row: 1 / span 2; }
.opt:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.opt:has(input:checked) .mark-o { background: var(--accent); box-shadow: inset 0 0 0 4px var(--paper), 0 0 0 1.5px var(--accent); }
.opt.multi:has(input:checked) .mark-o { box-shadow: none; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M5 9.4l2.6 2.6L13 6.6' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat; }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt.picked { box-shadow: inset 0 0 0 1px var(--accent-line); }
.answers { display: flex; flex-direction: column; gap: var(--s1); }
.answers .a { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.answers .a b { font-weight: 600; }

/* 下に固定の帯（問いに答える・書類に返事をする） */
.dock-space { height: calc(80px + env(safe-area-inset-bottom, 0px)); }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom, 0px));
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 var(--line);
}
.dock .in { max-width: 36rem; margin: 0 auto; display: flex; gap: var(--s2); }
.dock .in > * { flex: 1; }
.dock .btn { min-height: 48px; }

/* ---- フォーム ------------------------------------------------------------------ */
form { margin: 0; }
.form { display: flex; flex-direction: column; gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 500; font-size: var(--fs-s); color: var(--dim); }
.field .req { color: var(--danger); margin-left: var(--s1); font-weight: 400; }
.field .help { font-size: var(--fs-s); color: var(--faint); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--s4); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--hit); padding: 8px var(--s3); border: 0; border-radius: var(--r);
  background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; letter-spacing: 0.01em;
  box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow 0.15s var(--ease);
}
@media (min-width: 761px) {
  input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="url"], input[type="search"], select, textarea { font-size: var(--fs-m); }
}
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
input::placeholder, textarea::placeholder { color: rgb(103 107 114 / 75%); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: var(--s6); }
.check { display: inline-flex; gap: var(--s2); align-items: center; min-height: var(--hit); cursor: pointer; color: var(--dim); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.choices { display: flex; flex-wrap: wrap; gap: var(--s2); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2); cursor: pointer; }
.choice input:checked + span { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 500; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.notice, .error { padding: var(--s3) var(--s4); border-radius: var(--r); text-align: center; }
.notice { background: var(--good-soft); color: var(--good); }
.error { background: var(--danger-soft); color: var(--danger); }

/* ログイン・招待（中央の板 1 枚） */
.auth { min-height: calc(100dvh - var(--bar)); display: grid; place-items: center; padding: var(--s6) var(--s4); }
.auth .plate { width: min(100%, 25rem); padding: var(--s6) var(--s5); display: flex; flex-direction: column; gap: var(--s5); }
.auth h1 { font-size: var(--fs-xl); text-align: center; }
.auth .lead { text-align: center; color: var(--dim); margin-top: calc(-1 * var(--s3)); }

/* ---- 書類（A4） ------------------------------------------------------------------ */
.doc-wrap { overflow-x: auto; }
.doc {
  width: 210mm; max-width: 100%; min-height: 270mm; margin: 0 auto; padding: 18mm 16mm;
  background: #fff; color: #111; box-shadow: var(--plate), 0 24px 60px -36px rgb(20 28 45 / 28%); border-radius: 4px;
  font-size: 13px; line-height: 1.7; letter-spacing: 0.02em; display: flex; flex-direction: column; gap: 22px;
}
@media (max-width: 760px) { .doc { padding: 24px 18px; min-height: 0; border-radius: var(--r-plate); } }
.doc .title { text-align: center; font-size: 20px; letter-spacing: 0.4em; font-weight: 600; }
.doc .parties { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 520px) { .doc .parties { grid-template-columns: 1fr; } .doc .from { text-align: left; } .doc .meta { justify-content: start; } }
.doc .to { font-size: 16px; border-bottom: 1px solid #111; padding-bottom: 4px; }
.doc .from { text-align: right; font-size: 12px; }
.doc .from b { font-size: 14px; font-weight: 600; }
.doc .meta { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 0 14px; font-size: 12px; }
.doc .total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; background: #f3f4f6; font-size: 14px; }
.doc .total b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.doc table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.doc th, .doc td { border-bottom: 1px solid #d6d8dc; padding: 8px 6px; text-align: left; vertical-align: top; }
.doc th { font-weight: 500; font-size: 12px; color: #555; border-bottom: 1px solid #111; }
.doc td.n, .doc th.n { text-align: right; white-space: nowrap; }
.doc .sum { margin-left: auto; width: min(100%, 20rem); }
.doc .sum td { border: 0; padding: 3px 6px; }
.doc .sum tr.g td { border-top: 1px solid #111; font-weight: 600; padding-top: 6px; }
.doc .notes { border-top: 1px solid #d6d8dc; padding-top: 12px; }
.doc .notes h4 { margin: 0 0 6px; font-size: 12px; color: #555; font-weight: 500; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff; }
  .bar, .tabbar, .dock, .dock-space, .no-print { display: none !important; }
  main { padding: 0 !important; }
  .doc { box-shadow: none; border-radius: 0; width: 210mm; min-height: 297mm; }
}

/* 明細の入力 */
.items { width: 100%; border-collapse: collapse; }
.items th { font-weight: 500; font-size: var(--fs-s); color: var(--faint); text-align: left; padding: 0 6px 6px; }
.items td { padding: 4px 6px; vertical-align: top; }
.items td input, .items td select { min-height: 36px; }
.items .n input { text-align: right; }
@media (max-width: 640px) {
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 10px 0; box-shadow: inset 0 1px 0 var(--line); }
  .items td { padding: 0; }
  .items td.name { grid-column: 1 / -1; }
}

/* 写せる文（LINE に貼る） */
.copybox { display: flex; gap: var(--s2); align-items: stretch; }
.copybox textarea { min-height: 64px; font-size: var(--fs-s); }

/* 知らせ（下からの短い表示）・確かめ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100vw - 32px); padding: var(--s3) var(--s4); border-radius: 12px; background: rgb(255 255 255 / 92%);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--lift);
}
@media (max-width: 760px) { body.has-tabbar .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }

/* メニュー（自分） */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-grid; place-items: center; width: var(--hit); height: var(--hit); border-radius: var(--r); }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--fill); }
.menu > summary .avatar { width: 28px; height: 28px; font-size: 11px; }
.menu .pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 14rem; padding: 6px; z-index: 30;
  border-radius: 12px; background: rgb(255 255 255 / 94%); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--lift); display: flex; flex-direction: column;
}
.menu .pop a, .menu .pop button { display: flex; align-items: center; min-height: var(--hit); padding: 0 var(--s3); border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.menu .pop a:hover, .menu .pop button:hover { background: var(--fill); }
.menu .pop .who { padding: var(--s2) var(--s3); color: var(--faint); font-size: var(--fs-s); line-height: 1.5; box-shadow: inset 0 -1px 0 var(--line); margin-bottom: var(--s1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- 小さな道具（ページの中に style を書かない：CSP の style-src 'self'） ---- */
.inline { display: inline; }
.grow { flex: 1 1 12rem; width: auto; }
.scroll-x { overflow-x: auto; }
.search-input { max-width: 26rem; }
.st-label { display: inline-flex; align-items: center; gap: 6px; }
.with-face { display: flex !important; align-items: center; gap: var(--s3); }
.amount { color: var(--ink); font-size: var(--fs-m); font-variant-numeric: tabular-nums; }
.light { font-weight: 400; }
.col.tight { gap: var(--s5); }
.actions.tight { gap: var(--s1); }
.msg-actions { margin-top: var(--s1); }
.linkbtn { border: 0; background: none; padding: 0; cursor: pointer; font-size: inherit; color: var(--accent); }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.linkbtn.danger { color: var(--danger); }
.select-s { min-height: 28px !important; width: auto !important; padding: 0 28px 0 8px !important; font-size: var(--fs-s) !important; }
details.note-row { display: block; }
details.note-row > summary { cursor: pointer; list-style: none; }
details.note-row > summary::-webkit-details-marker { display: none; }
.note-body { padding-top: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
.kv.boxed { padding: 0 var(--s4); border-radius: var(--r); background: var(--paper-2); }
.w-qty { width: 5rem; } .w-unit { width: 4rem; } .w-price { width: 8rem; } .w-tax { width: 5.5rem; }
.doc-page { gap: var(--s5); }
.doc .to-block { display: flex; flex-direction: column; gap: 14px; }
.doc .issuer { margin-top: 12px; }
.doc .pre { white-space: pre-line; }
.doc .item-note { font-size: 11px; color: #666; }
.dock .col-dock { flex-direction: column; }
.dock .col-dock > .in { width: 100%; }
.dock-space.tall { height: calc(128px + env(safe-area-inset-bottom, 0px)); }

/* ファイルを選ぶ（ブラウザの既定のボタンを、押すものの見た目にそろえる） */
input[type="file"] { font: inherit; font-size: var(--fs-s); color: var(--faint); max-width: 100%; }
input[type="file"]::file-selector-button { margin-right: var(--s3); min-height: 36px; padding: 0 var(--s4); border: 0; border-radius: var(--r); background: var(--paper); box-shadow: var(--plate); font: inherit; font-weight: 500; color: var(--ink); cursor: pointer; }
