/* 契約管理 — Apple のアプリの設計に沿ったスタイル（システムフォント・グループ化したリスト・半透明のバー・シート） */
:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #f7f7fa;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.08);
  --sep: rgba(60, 60, 67, 0.16);
  --label: #1c1c1e;
  --label-2: rgba(60, 60, 67, 0.72);
  --label-3: rgba(60, 60, 67, 0.46);
  --tint: #0a66ff;
  --tint-press: #0052d9;
  --tint-soft: rgba(10, 102, 255, 0.1);
  --green: #1a9e4b;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #c26a00;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #e5342a;
  --red-soft: rgba(255, 59, 48, 0.12);
  --bar: rgba(247, 247, 250, 0.78);
  --scrim: rgba(0, 0, 0, 0.32);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.03);
  --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-s: 10px;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --sidebar: 320px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --font-serif: "Noto Serif JP", "Hiragino Mincho ProN", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --bg-elev-2: #242426;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.16);
    --sep: rgba(84, 84, 88, 0.6);
    --label: #f5f5f7;
    --label-2: rgba(235, 235, 245, 0.66);
    --label-3: rgba(235, 235, 245, 0.4);
    --tint: #3b8bff;
    --tint-press: #6aa6ff;
    --tint-soft: rgba(59, 139, 255, 0.18);
    --green: #32d74b;
    --green-soft: rgba(50, 215, 75, 0.16);
    --orange: #ffb340;
    --orange-soft: rgba(255, 159, 10, 0.2);
    --red: #ff6961;
    --red-soft: rgba(255, 69, 58, 0.18);
    --bar: rgba(22, 22, 24, 0.78);
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-1: none;
    --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: 400 15px/1.55 var(--font); letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--tint); text-decoration: none; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--bg-elev); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- タイポグラフィ（大きい見出しは字間を詰める） ---- */
.large-title { font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.title-1 { font-size: 26px; line-height: 1.18; font-weight: 700; letter-spacing: -0.015em; margin: 0; }
.title-2 { font-size: 21px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.headline { font-size: 16px; font-weight: 600; }
.footnote { font-size: 13px; color: var(--label-2); line-height: 1.5; }
.caption { font-size: 12px; color: var(--label-3); letter-spacing: 0.02em; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--label-2); letter-spacing: 0.02em; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0; word-break: break-all; }
.num { font-variant-numeric: tabular-nums; }

/* ---- ボタン（押した瞬間に反応） ---- */
.btn {
  appearance: none; border: 0; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  font-size: 16px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--fill); color: var(--tint);
  transition: transform 120ms var(--ease), background-color 160ms var(--ease), opacity 160ms var(--ease);
  -webkit-touch-callout: none;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--tint); color: #fff; }
.btn.primary:active { background: var(--tint-press); }
.btn.danger { color: var(--red); }
.btn.plain { background: transparent; padding: 0 8px; min-height: 36px; font-weight: 500; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.busy { opacity: 0.4; pointer-events: none; }
.btn.busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
.icon-btn { appearance: none; border: 0; background: transparent; color: var(--tint); width: 44px; height: 44px; border-radius: 22px; display: inline-grid; place-items: center; cursor: pointer; transition: transform 120ms var(--ease), background 160ms; }
.icon-btn:active { transform: scale(0.92); background: var(--fill-2); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- レイアウト ---- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow: auto; overscroll-behavior: contain;
  background: color-mix(in srgb, var(--bg-elev-2) 86%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid var(--sep);
  padding: 0 0 24px;
}
.main { min-width: 0; }
.pane { max-width: 860px; margin: 0 auto; padding: 8px 28px 120px; }
@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .shell.has-detail .sidebar { display: none; }
  .shell:not(.has-detail) .main { display: none; }
  .pane { padding: 4px 16px calc(110px + env(safe-area-inset-bottom)); }
}

/* 半透明のナビゲーションバー（スクロールすると縁が出る） */
.navbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px; min-height: 52px; padding: env(safe-area-inset-top) 12px 0;
  background: var(--bar); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid transparent; transition: border-color 200ms var(--ease);
}
.navbar.scrolled { border-bottom-color: var(--sep); }
.navbar .nav-title { flex: 1; text-align: center; font-weight: 600; font-size: 16px; opacity: 0; transform: translateY(4px); transition: opacity 200ms var(--ease), transform 200ms var(--ease); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar.scrolled .nav-title { opacity: 1; transform: none; }
.navbar .back { white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; color: var(--tint); font-size: 16px; padding: 0 8px 0 2px; min-height: 44px; background: none; border: 0; cursor: pointer; }
.navbar .back:active { opacity: 0.5; }
.navbar .back svg { width: 24px; height: 24px; margin-right: -2px; }
.nav-side { min-width: 88px; display: flex; align-items: center; }
.nav-side.right { justify-content: flex-end; }
.side-head { padding: calc(14px + env(safe-area-inset-top)) 18px 6px; }
.side-head .row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }

/* 検索と絞り込み */
.search { position: relative; margin: 12px 0 10px; }
.search input { width: 100%; height: 38px; border: 0; border-radius: 11px; background: var(--fill); padding: 0 12px 0 34px; outline: none; font-size: 15px; }
.search svg { position: absolute; left: 10px; top: 9px; width: 18px; height: 18px; color: var(--label-3); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 10px; padding: 2px; position: relative; }
.segmented button { appearance: none; border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--label); position: relative; z-index: 1; transition: color 160ms; }
.segmented button[aria-pressed="true"] { font-weight: 600; }
.segmented .thumb { position: absolute; top: 2px; bottom: 2px; border-radius: 8px; background: var(--bg-elev); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04); transition: transform 320ms var(--spring), width 320ms var(--spring); }
@media (prefers-color-scheme: dark) { .segmented .thumb { background: #636366; } }

/* ---- グループ化したリスト ---- */
.group { background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1); }
.group + .group { margin-top: 12px; }
.section { margin: 26px 0 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 8px; }
.section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-foot { margin: 8px 16px 0; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; position: relative;
  color: inherit; background: transparent; border: 0; width: 100%; text-align: left; cursor: default;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
.row.link { cursor: pointer; transition: background-color 120ms; }
.row.link:active, .row.link.pressed { background: var(--fill-2); }
@media (hover: hover) { .row.link:hover { background: var(--fill-2); } }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--label-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .trail { color: var(--label-3); display: flex; align-items: center; gap: 6px; font-size: 14px; flex-shrink: 0; }
.chev { width: 8px; height: 13px; color: var(--label-3); flex-shrink: 0; }
.lead { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--tint-soft); color: var(--tint); }
.lead svg { width: 20px; height: 20px; }
.lead.green { background: var(--green-soft); color: var(--green); }
.lead.orange { background: var(--orange-soft); color: var(--orange); }
.lead.gray { background: var(--fill); color: var(--label-2); }

/* 案件一覧 */
.deal-list { padding: 4px 10px; }
.deal-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 11px 12px; cursor: pointer; color: inherit; position: relative; transition: background-color 120ms; }
.deal-item:active { transform: scale(0.99); }
.deal-item[aria-current="page"] { background: var(--tint); color: #fff; }
.deal-item[aria-current="page"] .sub, .deal-item[aria-current="page"] .caption { color: rgba(255, 255, 255, 0.8); }
@media (hover: hover) { .deal-item:not([aria-current="page"]):hover { background: var(--fill-2); } }
.deal-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.deal-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-item .sub { font-size: 13px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-item .dot { position: absolute; left: -2px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--tint); }
.deal-item[aria-current="page"] .dot { background: #fff; }
.deal-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; }

/* ステータスのしるし */
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--label-2); white-space: nowrap; }
.pill.blue { background: var(--tint-soft); color: var(--tint); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }
.deal-item[aria-current="page"] .pill { background: rgba(255, 255, 255, 0.22); color: #fff; }
.pill svg { width: 12px; height: 12px; }

/* ---- 案件ヘッダーと進み具合 ---- */
.hero { padding: 10px 4px 4px; }
.hero .eyebrow { margin-bottom: 4px; }
.hero .meta svg { width: 15px; height: 15px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.steps { display: grid; grid-template-columns: repeat(7, 1fr); margin: 22px 0 6px; position: relative; }
.step { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; border: 0; background: none; padding: 0; cursor: pointer; color: var(--label-3); font-size: 12px; font-weight: 500; }
.step::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--sep); z-index: 0; }
.step:first-child::before { display: none; }
.step.done::before, .step.skipped::before, .step.current::before { background: var(--tint); }
.step .mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elev); border: 2px solid var(--sep); position: relative; z-index: 1; transition: transform 300ms var(--spring), background 200ms; }
.step .mark svg { width: 15px; height: 15px; }
.step.done .mark { background: var(--tint); border-color: var(--tint); color: #fff; }
.step.skipped .mark { border-style: dashed; border-color: var(--tint); color: var(--tint); }
.step.current .mark { border-color: var(--tint); box-shadow: 0 0 0 5px var(--tint-soft); }
.step.current .mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--tint); }
.step.current, .step.done, .step.skipped { color: var(--label); }
.step:active .mark { transform: scale(0.9); }
.step .note { font-size: 11px; color: var(--label-3); font-weight: 400; text-align: center; min-height: 15px; }
@media (max-width: 600px) { .step { font-size: 10.5px; white-space: nowrap; letter-spacing: -0.03em; } .step .note { display: none; } .step .mark { width: 24px; height: 24px; } .step::before { top: 11px; } }

/* 次にやること */
.callout { margin-top: 18px; border-radius: 18px; padding: 18px 18px 16px; background: linear-gradient(180deg, color-mix(in srgb, var(--tint) 10%, var(--bg-elev)), var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--tint) 18%, transparent); display: grid; gap: 12px; }
.callout .eyebrow { color: var(--tint); }
.callout .title-2 { font-size: 19px; }
.callout .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.callout.done { background: linear-gradient(180deg, color-mix(in srgb, var(--green) 10%, var(--bg-elev)), var(--bg-elev)); border-color: color-mix(in srgb, var(--green) 20%, transparent); }
.callout.done .eyebrow { color: var(--green); }

/* ---- 文書の画面 ---- */
.doc-head { padding: 6px 4px 0; }
.doc-tabs { margin: 16px 0 14px; }
.reader { background: var(--bg-elev); border-radius: var(--radius); padding: 28px 26px 30px; box-shadow: var(--shadow-1); font-family: var(--font-serif); font-size: 15.5px; line-height: 1.95; letter-spacing: 0.02em; }
.reader h1 { font-size: 22px; text-align: center; letter-spacing: 0.3em; margin: 4px 0 2px; font-weight: 700; }
.reader .subtitle { text-align: center; color: var(--label-2); font-size: 13px; letter-spacing: 0.2em; margin: 0 0 18px; }
.reader .preamble { text-indent: 1em; margin: 18px 0 8px; }
.article { margin: 20px 0 0; border-radius: 12px; padding: 6px 10px 8px; margin-left: -10px; margin-right: -10px; transition: background-color 200ms; position: relative; }
.article.highlight { background: var(--tint-soft); }
.article h3 { font-size: 15.5px; margin: 0 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.article p { margin: 2px 0; text-align: justify; }
.article .kou { padding-left: 1.6em; text-indent: -1.6em; }
.article .kou.solo { padding-left: 0; text-indent: 1em; }
.article .gou { padding-left: 3.4em; text-indent: -2.6em; }
.cm-btn { font-family: var(--font); appearance: none; border: 0; background: var(--fill-2); color: var(--label-2); height: 28px; min-width: 28px; padding: 0 9px; border-radius: 14px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; transition: transform 120ms var(--ease), background 160ms; letter-spacing: 0; }
.cm-btn svg { width: 14px; height: 14px; }
.cm-btn.has { background: var(--orange-soft); color: var(--orange); }
.cm-btn:active { transform: scale(0.94); }
.reader .closing { text-indent: 1em; margin-top: 22px; }
.reader .parties { font-family: var(--font); font-size: 13.5px; margin-top: 18px; display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.reader .parties > div { background: var(--bg-elev-2); border-radius: 12px; padding: 12px 14px; line-height: 1.7; }
@media (max-width: 600px) { .reader { padding: 22px 18px; font-size: 15px; } .reader .parties { grid-template-columns: 1fr; } }

mark.blank { background: var(--orange-soft); color: var(--orange); border-radius: 4px; padding: 0 3px; font-family: var(--font); font-size: 0.88em; }
.pdf-actions { display: flex; gap: 8px; margin: 10px 0 0; flex-wrap: wrap; }

/* フォーム */
.field { padding: 12px 16px; position: relative; display: block; }
.field + .field::before, .field + .row::before, .row + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
.field label, .field .label { display: block; font-size: 13px; font-weight: 600; color: var(--label-2); margin-bottom: 4px; }
.field .req { color: var(--red); margin-left: 4px; font-weight: 500; }
.field input[type=text], .field input[type=email], .field input[type=date], .field input[inputmode], .field textarea, .field select {
  width: 100%; border: 0; outline: none; background: transparent; font-size: 16px; padding: 4px 0; resize: none; line-height: 1.55;
}
.field textarea { min-height: 52px; field-sizing: content; }
.field input::placeholder, .field textarea::placeholder { color: var(--label-3); }
.field .help { font-size: 12.5px; color: var(--label-3); margin-top: 4px; line-height: 1.5; }
.field.readonly .value { font-size: 16px; white-space: pre-wrap; }
.field.invalid label { color: var(--red); }
.switch-row { display: flex; align-items: center; gap: 12px; }
.switch-row .body { flex: 1; }
.switch { appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; cursor: pointer; flex-shrink: 0; transition: background 250ms var(--ease); margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.06); transition: transform 300ms var(--spring); }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.choice { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.choice button { appearance: none; border: 1.5px solid var(--sep); background: transparent; border-radius: 12px; padding: 10px 14px; cursor: pointer; text-align: left; flex: 1 1 200px; transition: border-color 160ms, background 160ms, transform 120ms; }
.choice button:active { transform: scale(0.98); }
.choice button[aria-pressed="true"] { border-color: var(--tint); background: var(--tint-soft); }
.choice button b { display: block; font-size: 15px; }
.choice button span { display: block; font-size: 12.5px; color: var(--label-2); margin-top: 2px; }

/* 見積の明細 */
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; color: var(--label-2); font-weight: 600; text-align: left; padding: 8px 6px; }
.items td { padding: 4px 6px; border-top: 1px solid var(--sep); vertical-align: top; }
.items input { width: 100%; border: 0; background: transparent; outline: none; padding: 8px 0; font-size: 15px; }
.items input.r { text-align: right; font-variant-numeric: tabular-nums; }
.items .amt { text-align: right; padding-top: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; padding: 12px 16px 16px; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
@media (max-width: 600px) { .items .hide-sm { display: none; } }

/* 下部の操作バー（合意・保存） */
.bottombar {
  position: fixed; left: var(--sidebar); right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bar); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--sep);
  transform: translateY(0); transition: transform 360ms var(--spring);
}
.bottombar.hidden { transform: translateY(110%); }
.bottombar .inner { max-width: 860px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.bottombar .status { flex: 1; min-width: 0; font-size: 13px; color: var(--label-2); display: flex; gap: 10px; flex-wrap: wrap; }
.bottombar .status b { color: var(--label); font-weight: 600; }
@media (max-width: 899px) { .bottombar { left: 0; } }
.agree-state { display: inline-flex; align-items: center; gap: 4px; }
.agree-state svg { width: 16px; height: 16px; }
.agree-state.ok { color: var(--green); }

/* コメント */
.comment { display: flex; gap: 10px; padding: 12px 16px; position: relative; }
.comment + .comment::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; background: linear-gradient(180deg, #8e8e93, #636366); }
.avatar.ours { background: linear-gradient(180deg, #3b8bff, #0a57d6); }
.avatar.theirs { background: linear-gradient(180deg, #34c759, #1a9e4b); }
.comment .who { font-size: 13px; font-weight: 600; }
.comment .who .caption { font-weight: 400; margin-left: 6px; }
.comment .text { white-space: pre-wrap; margin-top: 2px; }
.comment.resolved .text { color: var(--label-3); text-decoration: line-through; text-decoration-color: var(--label-3); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; }
.composer textarea { flex: 1; border: 1px solid var(--sep); border-radius: 20px; padding: 9px 14px; background: var(--bg-elev); outline: none; resize: none; min-height: 40px; max-height: 160px; field-sizing: content; font-size: 16px; line-height: 1.45; }
.composer .send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--tint); color: #fff; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; transition: transform 120ms var(--ease), opacity 160ms; margin-bottom: 2px; }
.composer .send:disabled { opacity: 0.35; }
.composer .send:active { transform: scale(0.9); }
.composer .send svg { width: 18px; height: 18px; }

/* 相談（メッセージ） */
.chat { display: flex; flex-direction: column; gap: 4px; padding: 12px 4px 16px; min-height: calc(100dvh - 300px); justify-content: flex-end; }
.bubble-wrap { display: flex; flex-direction: column; max-width: 78%; }
.bubble-wrap.me { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 14px; border-radius: 20px; white-space: pre-wrap; word-break: break-word; background: var(--bg-elev); box-shadow: var(--shadow-1); line-height: 1.5; animation: pop 360ms var(--spring); }
.bubble-wrap.me .bubble { background: var(--tint); color: #fff; box-shadow: none; }
.bubble-meta { font-size: 11.5px; color: var(--label-3); margin: 6px 10px 2px; }
@keyframes pop { from { transform: scale(0.92) translateY(6px); opacity: 0; } }
.chat-composer { position: sticky; bottom: 0; background: var(--bar); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); border-top: 1px solid var(--sep); margin: 0 -28px; padding-bottom: env(safe-area-inset-bottom); }
@media (max-width: 899px) { .chat-composer { margin: 0 -16px; } }

/* 署名 */
.sign-steps { display: flex; gap: 8px; margin: 18px 0 4px; }
.sign-steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--fill); transition: background 300ms; }
.sign-steps span.on { background: var(--tint); }
.pdf-frame { width: 100%; height: min(72vh, 900px); border: 0; border-radius: var(--radius); background: var(--bg-elev); box-shadow: var(--shadow-1); display: block; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { appearance: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--label-3); flex-shrink: 0; margin: 1px 0 0; display: grid; place-items: center; transition: background 160ms, border-color 160ms, transform 160ms var(--spring); cursor: pointer; }
.check input:checked { background: var(--tint); border-color: var(--tint); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input:active { transform: scale(0.9); }
.otp { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.otp input { width: 46px; height: 58px; text-align: center; font-size: 26px; font-weight: 600; border-radius: 12px; border: 0; background: var(--fill); outline: none; caret-color: var(--tint); font-variant-numeric: tabular-nums; transition: box-shadow 160ms; }
.otp input:focus { box-shadow: 0 0 0 2px var(--tint); background: var(--bg-elev); }
.otp.shake { animation: shake 420ms var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (max-width: 380px) { .otp input { width: 40px; height: 52px; font-size: 22px; } }
.pad-wrap { position: relative; background: #fff; color: #1c1c1e; border: 1px solid var(--sep); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.pad { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
.pad-line { position: absolute; left: 24px; right: 24px; bottom: 48px; border-bottom: 1.5px dashed rgba(0, 0, 0, 0.18); pointer-events: none; }
.pad-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 12px; color: rgba(0, 0, 0, 0.4); pointer-events: none; }
.pad-tools { position: absolute; right: 8px; top: 8px; }
.pad-tools .btn { background: rgba(0, 0, 0, 0.06); color: #0a66ff; }
.typed-preview { height: 120px; display: grid; place-items: center; font-family: var(--font-serif); font-size: 40px; letter-spacing: 0.08em; }
.success { text-align: center; padding: 48px 16px 24px; }
.success .ring { width: 88px; height: 88px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; margin: 0 auto 18px; animation: pop 520ms var(--spring); }
.success .ring svg { width: 46px; height: 46px; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 520ms 180ms var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* 保存（締結済み） */
.file-card { padding: 16px; display: grid; gap: 10px; }
.file-card + .file-card { border-top: 1px solid var(--sep); }
.file-card .top { display: flex; gap: 12px; align-items: center; }
.hash { background: var(--fill-2); border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.hash .mono { flex: 1; }

/* ---- シート（下から出る／PCは中央） ---- */
.sheet-root { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; justify-items: center; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 320ms var(--ease); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-2);
  transform: translateY(100%); transition: transform 420ms var(--spring);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-root.open .sheet-scrim { opacity: 1; }
.sheet-root.open .sheet { transform: none; }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); opacity: 0.5; margin: 6px auto 0; }
.sheet .sheet-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; min-height: 52px; padding: 0 8px; background: var(--bar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.sheet .sheet-bar .t { flex: 1; text-align: center; font-weight: 600; }
.sheet .sheet-body { padding: 8px 16px 24px; }
@media (min-width: 900px) {
  .sheet-root { align-items: center; }
  .sheet { border-radius: 18px; transform: translateY(24px) scale(0.98); opacity: 0; transition: transform 380ms var(--spring), opacity 240ms var(--ease); max-height: min(86dvh, 900px); }
  .sheet-root.open .sheet { opacity: 1; }
  .sheet .grabber { display: none; }
}

/* アクションシート（確認） */
.alert { max-width: 300px; width: calc(100% - 48px); border-radius: 16px; background: color-mix(in srgb, var(--bg-elev) 92%, transparent); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); text-align: center; overflow: hidden; transform: scale(1.08); opacity: 0; transition: transform 300ms var(--spring), opacity 200ms; align-self: center; position: relative; }
.sheet-root.open .alert { transform: none; opacity: 1; }
.alert .a-body { padding: 20px 18px 16px; }
.alert .a-title { font-weight: 600; font-size: 17px; }
.alert .a-msg { font-size: 13px; margin-top: 4px; color: var(--label-2); white-space: pre-line; }
.alert .a-actions { display: grid; grid-auto-flow: column; border-top: 1px solid var(--sep); }
.alert .a-actions button { appearance: none; border: 0; background: transparent; min-height: 46px; font-size: 17px; color: var(--tint); cursor: pointer; }
.alert .a-actions button + button { border-left: 1px solid var(--sep); }
.alert .a-actions button.strong { font-weight: 600; }
.alert .a-actions button.danger { color: var(--red); }
.alert .a-actions button:active { background: var(--fill-2); }

/* トースト */
#toasts { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast { background: color-mix(in srgb, var(--label) 88%, transparent); color: var(--bg); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); padding: 11px 18px; border-radius: 22px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-2); display: flex; align-items: center; gap: 8px; animation: toast-in 420ms var(--spring); }
.toast.error { background: var(--red); color: #fff; }
.toast.out { animation: toast-out 240ms var(--ease) forwards; }
.toast svg { width: 18px; height: 18px; }
@keyframes toast-in { from { transform: translateY(-16px) scale(0.96); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-10px); opacity: 0; } }

/* ログイン */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: 17px; box-shadow: 0 8px 24px rgba(10, 87, 214, 0.25); margin-bottom: 18px; }
.login .group { text-align: left; margin-top: 24px; }
.login .field input { font-size: 17px; }

/* 読み込み中・空の状態 */
.skeleton { background: linear-gradient(90deg, var(--fill-2) 25%, var(--fill) 37%, var(--fill-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 64px 24px; color: var(--label-2); }
.empty svg { width: 56px; height: 56px; color: var(--label-3); margin-bottom: 12px; }
.empty .title-2 { color: var(--label); margin-bottom: 6px; }

/* 画面の切り替え（スマホは横から押し出す） */
.view-enter { animation: view-in 420ms var(--spring); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 899px) {
  .view-enter.push { animation: push-in 420ms var(--spring); }
  .view-enter.pop { animation: pop-in 420ms var(--spring); }
  @keyframes push-in { from { transform: translateX(30%); opacity: 0.4; } }
  @keyframes pop-in { from { transform: translateX(-20%); opacity: 0.4; } }
}

.kv { display: grid; grid-template-columns: 9.5em 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--label-2); }
.kv dd { margin: 0; white-space: pre-wrap; }
.stack { display: grid; gap: 10px; }
.hstack { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.timeline .row { align-items: flex-start; }
.timeline .row .title { font-weight: 400; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .sheet-root .sheet, .sheet-root .alert { transition: opacity 200ms !important; transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .navbar, .bottombar, .sidebar, .sheet .sheet-bar, .chat-composer { background: var(--bg-elev); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --sep: rgba(60, 60, 67, 0.5); --label-2: rgba(60, 60, 67, 0.9); }
  .group { border: 1px solid var(--sep); }
}
@media print {
  .sidebar, .navbar, .bottombar, #toasts { display: none !important; }
  .shell { display: block; }
}
