/* 見積管理 — 契約管理（contract.mng.tanasuke.com）と同じ設計（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);
  --purple: #6e3fd6; --purple-soft: rgba(110, 63, 214, 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-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);
    --purple: #b48cff; --purple-soft: rgba(180, 140, 255, 0.18);
    --bar: rgba(22, 22, 24, 0.78); --scrim: rgba(0, 0, 0, 0.55);
    --shadow-1: none;
    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; }
.tc { text-align: center; }
.red { color: var(--red); }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt24 { margin-top: 24px; } .mb6 { margin-bottom: 6px; }
.grow { flex: 1; min-width: 0; }
.pre { white-space: pre-wrap; }

/* ---- ボタン ---- */
.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; }
.pane.wide { max-width: 1040px; }
@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; gap: 2px; }
.side-head { padding: calc(14px + env(safe-area-inset-top)) 18px 6px; }
.side-head .row { display: flex; align-items: center; justify-content: space-between; padding: 0; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.side-title { margin-top: 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, .field + .row::before, .row + .field::before, .line + .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 .sub.wrap { white-space: normal; }
.row .trail { color: var(--label-3); display: flex; align-items: center; gap: 6px; font-size: 14px; flex-shrink: 0; }
.row .trail b { color: var(--label); font-variant-numeric: tabular-nums; }
.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.purple { background: var(--purple-soft); color: var(--purple); }
.lead.gray { background: var(--fill); color: var(--label-2); }
.lead.red { background: var(--red-soft); color: var(--red); }

/* 一覧（サイドバー） */
.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-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
.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); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.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 { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; align-items: center; }
.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.orange { background: linear-gradient(180deg, color-mix(in srgb, var(--orange) 10%, var(--bg-elev)), var(--bg-elev)); border-color: color-mix(in srgb, var(--orange) 22%, transparent); }
.callout.orange .eyebrow { color: var(--orange); }
.callout.green { 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.green .eyebrow { color: var(--green); }
.callout ul { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--bg-elev); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1); cursor: pointer; border: 0; text-align: left; color: inherit; transition: transform 120ms var(--ease); }
.stat:active { transform: scale(0.98); }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12.5px; color: var(--label-2); }
.amount-hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.amount-hero .big { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---- フォーム ---- */
.field { padding: 12px 16px; position: relative; display: block; }
.field + .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[type=number], .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); }
.field.picker { cursor: pointer; }
.field.picker .value { font-size: 16px; display: flex; align-items: center; gap: 8px; min-height: 26px; }
.field.picker .value .placeholder { color: var(--label-3); }
.field.picker .value .chev { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
.grid2 .field + .field::before { display: none; }
.grid2 .field:nth-child(2n)::after { content: ""; position: absolute; top: 12px; bottom: 12px; left: 0; width: 1px; background: var(--sep); }
.grid2 + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } .grid2 .field:nth-child(2n)::after { display: none; } .grid2 .field + .field::before { display: block; } }
.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 160px; transition: border-color 160ms, background 160ms, transform 120ms; color: inherit; }
.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; }
.dropzone { border: 1.5px dashed var(--sep); border-radius: 12px; padding: 14px; text-align: center; color: var(--label-2); font-size: 13px; margin: 0 16px 14px; }
.dropzone.over { border-color: var(--tint); background: var(--tint-soft); }
.dropzone label { color: var(--tint); cursor: pointer; font-weight: 600; }

/* ---- 明細の編集 ---- */
.line { padding: 10px 16px 12px; position: relative; display: grid; gap: 6px; }
.line + .line::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
.line .l-head { display: flex; gap: 8px; align-items: center; }
.line .l-no { width: 22px; height: 22px; border-radius: 11px; background: var(--fill); color: var(--label-2); font-size: 12px; font-weight: 600; display: grid; place-items: center; flex-shrink: 0; }
.line.text .l-no { background: var(--orange-soft); color: var(--orange); }
.line input, .line textarea, .line select { border: 0; outline: none; background: transparent; font-size: 16px; padding: 4px 0; line-height: 1.5; }
.line .l-name { flex: 1; min-width: 0; font-weight: 500; }
.line .l-desc { width: 100%; font-size: 13.5px; color: var(--label-2); resize: none; field-sizing: content; min-height: 24px; padding: 0; }
.line .l-desc::placeholder, .line .l-name::placeholder { color: var(--label-3); }
.line .l-nums { display: grid; grid-template-columns: 74px 64px 1fr 72px auto; gap: 10px; align-items: center; }
.line .l-nums label { display: grid; gap: 1px; font-size: 11px; color: var(--label-3); font-weight: 600; }
.line .l-nums input, .line .l-nums select { width: 100%; font-size: 15px; padding: 2px 0; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--sep); border-radius: 0; }
.line .l-nums input.r { text-align: right; }
.line .l-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 92px; font-size: 15px; align-self: end; padding-bottom: 3px; }
.line .l-ops { display: flex; gap: 2px; margin-left: auto; }
.line .l-ops button { appearance: none; border: 0; background: transparent; color: var(--label-3); width: 30px; height: 30px; border-radius: 15px; display: grid; place-items: center; cursor: pointer; }
.line .l-ops button:active { background: var(--fill-2); }
.line .l-ops button svg { width: 16px; height: 16px; }
.line .evidence { font-size: 12px; color: var(--label-3); display: flex; gap: 4px; align-items: center; }
.line .evidence svg { width: 13px; height: 13px; flex-shrink: 0; }
@media (max-width: 600px) { .line .l-nums { grid-template-columns: 1fr 1fr; } .line .l-amt { grid-column: 1 / -1; text-align: right; } .line .l-ops { grid-column: 1 / -1; justify-content: flex-end; } }
.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; }
.totals .k { color: var(--label-2); }
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; color: var(--label-2); font-weight: 600; text-align: left; padding: 8px 12px; }
.items td { padding: 8px 12px; border-top: 1px solid var(--sep); vertical-align: top; font-size: 14px; }
.items td.r, .items th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.items tr.text td { color: var(--label-2); font-weight: 600; background: var(--fill-2); }
.items .ev { font-size: 12px; color: var(--label-3); }
@media (max-width: 600px) { .items .hide-sm { display: none; } }
.json { background: var(--fill-2); border-radius: 12px; padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; margin: 0; }
.cmd { background: var(--fill-2); border-radius: 12px; padding: 12px 14px; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }

/* 下部の操作バー */
.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; align-items: center; }
.bottombar .status b { color: var(--label); font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 899px) { .bottombar { left: 0; } }

/* アバター */
.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); }

/* ---- シート・ダイアログ ---- */
.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.wide { max-width: 760px; }
.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(26, 158, 75, 0.28); margin-bottom: 18px; }
.login .group { text-align: left; margin-top: 24px; }
.login .field input { font-size: 17px; }
.login .note { margin: 10px 16px 22px; text-align: left; }
.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; } }

/* 読み込み中・空の状態 */
.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; }
.skeleton.s1 { width: 30%; height: 14px; margin-top: 14px; } .skeleton.s2 { width: 64%; height: 30px; margin-top: 12px; } .skeleton.s3 { width: 100%; height: 56px; margin-top: 28px; } .skeleton.s4 { width: 100%; height: 140px; margin-top: 20px; border-radius: 18px; } .skeleton.s5 { width: 100%; height: 200px; margin-top: 26px; border-radius: 14px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 64px 24px; color: var(--label-2); }
.empty.compact { padding: 40px 24px; }
.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; margin: 0; }
.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; }
.hstack.center { justify-content: center; }
.spacer { flex: 1; }
.timeline .row { align-items: flex-start; }
.timeline .row .title { font-weight: 400; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--sep); margin: 8px 0 12px; }
.tabs button { appearance: none; border: 0; background: transparent; padding: 8px 12px; font: inherit; color: var(--label-2); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs button[aria-pressed="true"] { color: var(--tint); border-bottom-color: var(--tint); font-weight: 600; }

@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 { 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; } }

/* 押すと一覧が開く入力欄（button なので UA のスタイルを消す） */
button.field.picker { appearance: none; border: 0; background: transparent; width: 100%; text-align: left; cursor: pointer; color: inherit; font: inherit; letter-spacing: inherit; transition: background-color 120ms; }
button.field.picker:active { background: var(--fill-2); }
@media (hover: hover) { button.field.picker:hover { background: var(--fill-2); } }
.field.picker .value { font-size: 16px; display: flex; align-items: center; gap: 8px; min-height: 26px; }
.field.picker .value .chev { margin-left: auto; }
.field.picker .help { text-align: left; }
.line .l-nums input, .line .l-nums select, .line .l-name { color: var(--label); }
