/* 見積シミュレーター — 明朝体を主にした、生成りとこげ茶の上品なデザイン */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --accent: #3A3228;                 /* 主役の色（設定で変えられる） */
  --ink: #3A3228;                    /* 文字 */
  --ink-2: #5E5347;
  --muted: #94897C;
  --bg: #FAF6F1;                     /* 生成り */
  --paper: #FFFFFF;
  --row: #F3EEE8;                    /* 項目の行 */
  --row-2: #ECE5DC;
  --line: #E8E0D5;
  --line-2: #D7CCBF;
  --gold: #A88B57;                   /* シャンパンゴールド */
  --gold-soft: #E8DCC4;
  --rose: #A64A6F;                   /* 値引き */
  --rose-tint: #F7EBF0;
  --blue: #52698A;                   /* 月額 */
  --tint: color-mix(in srgb, var(--accent) 6%, #FAF6F1);
  --tint-2: color-mix(in srgb, var(--accent) 12%, #FAF6F1);
  --edge: color-mix(in srgb, var(--accent) 30%, #FAF6F1);
  --on-accent: #FAF6F1;
  --deep: var(--accent);
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --latin: "Cormorant Garamond", "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --r: 10px;
  --r-sm: 6px;
  --shadow-1: 0 1px 2px rgba(58, 50, 40, .04);
  --shadow-2: 0 2px 6px rgba(58, 50, 40, .04), 0 14px 36px rgba(58, 50, 40, .08);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.8;
  letter-spacing: .04em;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "palt" 1;
  word-break: auto-phrase;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.num, .item-no, .step-no, .hero-no, .delta, .sim-en, .chip b, .pm-amt, .est-amt, .yen-input .yen, .doc-en, .doc-total strong, .doc-total-sub b, .doc-sim b, .doc-table td.c, .sum-head-en, .sheet-en {
  font-variant-numeric: lining-nums tabular-nums; font-feature-settings: "lnum" 1, "tnum" 1;
}
.num { font-family: var(--latin); font-variant-numeric: lining-nums tabular-nums; letter-spacing: .02em; font-feature-settings: "lnum" 1, "tnum" 1; }
.muted { color: var(--muted); font-weight: 400; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 上のバー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 8px 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-mark .bm-frame { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.brand-mark .bm-line { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
.brand-mark .bm-gold { fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; }
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-sub { font-family: var(--latin); font-size: 11px; font-weight: 600; color: var(--gold); letter-spacing: .22em; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .08em; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: stretch; }
.tbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 52px; padding: 4px 8px; border: 0; background: transparent; cursor: pointer;
  color: var(--ink); font-size: 10.5px; letter-spacing: .14em; line-height: 1.2;
  border-left: 1px solid var(--line);
}
.tbtn .ic { width: 22px; height: 22px; stroke-width: 1.3; }
.tbtn:hover { color: var(--gold); }

/* ---------- 表題 ---------- */
.hero {
  position: relative; text-align: center;
  padding: 30px 20px 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0)),
    radial-gradient(120% 90% at 50% 0%, #F1E9DE 0%, var(--bg) 70%);
  border-bottom: 1px solid var(--line);
}
.hero::before, .hero::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: rgba(255, 255, 255, .9); }
.hero::before { top: 4px; }
.hero::after { bottom: 4px; }
.hero-en { margin: 0; font-family: var(--latin); font-size: 34px; font-weight: 500; letter-spacing: .32em; line-height: 1.1; padding-left: .32em; color: var(--ink); }
.hero-ja { margin: 8px 0 0; font-size: 13px; font-weight: 600; letter-spacing: .4em; padding-left: .4em; }
.hero-lead { margin: 14px auto 0; max-width: 30em; font-size: 13px; color: var(--ink-2); letter-spacing: .06em; line-height: 1.9; }
.hero-no { margin: 10px 0 0; font-family: var(--latin); font-size: 14px; color: var(--gold); letter-spacing: .12em; }
.hero-no:empty { display: none; }
@media (max-width: 380px) {
  .brand-mark { width: 32px; height: 32px; }
  .brand-name { font-size: 14px; letter-spacing: .04em; }
  .tbtn { min-width: 46px; padding: 4px 6px; }
}
@media (min-width: 900px) {
  .hero { padding: 48px 24px 40px; }
  .hero-en { font-size: 46px; }
}

/* ---------- レイアウト ---------- */
.layout {
  max-width: 1120px; margin: 0 auto;
  padding: 8px 20px calc(136px + env(safe-area-inset-bottom));
  display: grid; gap: 24px;
}
.col-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; padding: 16px 24px 72px; align-items: start; }
  .col-side {
    position: sticky; top: 80px; margin: 20px -10px 0;
    max-height: calc(100vh - 92px); overflow-y: auto; overscroll-behavior: contain;
    padding: 8px 10px 24px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
  }
}
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }

/* 見出し（番号・日本語・英字） */
.step { display: flex; align-items: center; gap: 14px; margin: 26px 0 6px; }
.step-no {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--ink); color: var(--ink);
  font-family: var(--latin); font-size: 19px; font-weight: 600; line-height: 1;
  pointer-events: none;
}
.step-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-ja { font-size: 11.5px; font-weight: 600; letter-spacing: .24em; color: var(--ink-2); line-height: 1.5; }
.step-en { margin: 0; font-family: var(--latin); font-size: 24px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; line-height: 1.2; color: var(--ink); }
.step-count { margin-left: 10px; font-weight: 500; letter-spacing: .08em; color: var(--gold); }
.items-tools { display: flex; gap: 2px; align-self: flex-end; }

/* ---------- アコーディオンの共通 ---------- */
.acc-body {
  display: grid; grid-template-rows: 0fr; visibility: hidden;
  transition: grid-template-rows .36s var(--ease), visibility 0s linear .36s;
}
.open > .acc-body {
  grid-template-rows: 1fr; visibility: visible;
  transition: grid-template-rows .36s var(--ease), visibility 0s;
}
.acc-inner { overflow: hidden; min-height: 0; }
.chev { color: var(--ink-2); transition: transform .32s var(--ease); }
.open > .acc-head .chev, .open > .item-head .chev { transform: rotate(180deg); }

/* ---------- 入力欄 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .14em; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-width: 0; height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: #FFFEFC; font-size: 16px; font-weight: 500; letter-spacing: .04em;
  -webkit-appearance: none; appearance: none;
  transition: border-color .2s, box-shadow .2s;
}
textarea { height: auto; padding: 12px 14px; line-height: 1.8; resize: vertical; }
select {
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235E5347' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input[type=date] { line-height: 46px; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input::placeholder, textarea::placeholder { color: #B5AA9C; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}
input.center { text-align: center; }
.invalid { border-color: var(--rose) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--rose) 14%, transparent) !important; }
.shake { animation: shake .36s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.input-group { display: flex; gap: 8px; }
.input-group select { width: 96px; flex: none; }
.yen-input, .suffix-input { position: relative; }
.yen-input .yen {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--latin); font-size: 18px; color: var(--muted); pointer-events: none;
}
.yen-input input {
  padding-left: 32px !important; text-align: right;
  font-family: var(--latin); font-size: 21px !important; font-weight: 600 !important;
  font-variant-numeric: lining-nums tabular-nums; letter-spacing: .02em !important;
}
.suffix-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.suffix-input input { padding-right: 36px !important; text-align: right; }

/* 区分（一括・月額） */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-2); border-radius: 999px; background: #FFFEFC; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 5px 18px; border-radius: 999px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; letter-spacing: .14em; color: var(--muted);
  transition: background .2s, color .2s;
}
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }

/* チェックボックス */
.chk { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13.5px; font-weight: 600; letter-spacing: .1em; color: var(--ink-2); }
.chk input {
  -webkit-appearance: none; appearance: none; margin: 0;
  width: 20px; height: 20px; flex: none; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 3px; background: #FFFEFC;
  display: grid; place-items: center; transition: background .2s, border-color .2s;
}
.chk input::after {
  content: ""; width: 9px; height: 5px;
  border: 1.6px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px); opacity: 0;
}
.chk input:checked { background: var(--accent); border-color: var(--accent); }
.chk input:checked::after { opacity: 1; }
.chk input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.chk.danger input:checked { background: var(--rose); border-color: var(--rose); }
.chk.danger input:checked + span { color: var(--rose); }

/* ボタン（押せるものだけが、この形になる） */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 999px;
  font-size: 14.5px; font-weight: 600; letter-spacing: .14em; white-space: nowrap; cursor: pointer;
  transition: transform .08s, background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn.ghost { background: #FFFEFC; border-color: var(--line-2); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.sm { height: 40px; padding: 0 18px; font-size: 13px; }
.btn.block { width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two .btn { padding: 0 10px; font-size: 13px; letter-spacing: .08em; }
.link-btn {
  border: 0; background: none; cursor: pointer; padding: 6px 4px;
  color: var(--ink-2); font-size: 12.5px; font-weight: 600; letter-spacing: .1em;
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px;
}
.link-btn:hover { color: var(--ink); text-decoration-color: var(--ink); }
.link-btn.danger { color: var(--rose); }
.icon-btn {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--tint); }

/* ---------- お見積り情報 ---------- */
.info-head {
  width: 100%; min-height: 60px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border: 0; background: none; cursor: pointer; text-align: left;
}
.info-summary { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-summary.placeholder { color: var(--muted); font-weight: 500; }
.info-hint { flex: none; font-size: 12px; color: var(--ink-2); letter-spacing: .12em; }
.info.open .info-hint { display: none; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding: 6px 18px 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.span-2 { grid-column: 1 / -1; }

/* ---------- お見積り項目 ---------- */
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--row); border: 1px solid transparent; border-radius: var(--r);
  overflow: hidden; transition: background .25s, border-color .25s, box-shadow .25s;
  scroll-margin: 96px 0 160px;
}
.item:hover { background: var(--row-2); }
.item.open { background: var(--paper); border-color: var(--line); box-shadow: var(--shadow-2); }
.item-head {
  width: 100%; min-height: 66px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 12px 14px 12px 16px; border: 0; background: none; cursor: pointer; text-align: left;
}
.item-head:focus-visible { outline: 1.5px solid var(--ink); outline-offset: -3px; border-radius: var(--r); }
.item-no { font-family: var(--latin); font-size: 15px; font-weight: 600; color: var(--gold); letter-spacing: .04em; min-width: 20px; }
.item-main { min-width: 0; }
.item-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  font-size: 15.5px; font-weight: 600; line-height: 1.55; letter-spacing: .06em; overflow-wrap: anywhere;
}
.item-sub { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; letter-spacing: .04em; }
.sub-text { overflow: hidden; text-overflow: ellipsis; }
.tag { flex: none; font-size: 11px; font-weight: 600; letter-spacing: .12em; line-height: 1; }
.tag.monthly { color: var(--blue); }
.tag.discount { color: var(--rose); }
.tag + .sub-text::before, .tag + .tag::before { content: "／"; margin-right: 6px; color: var(--line-2); }
.item-amt { font-family: var(--latin); font-size: 21px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; letter-spacing: .02em; }
.item-amt small { font-family: var(--serif); font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.item-amt.neg { color: var(--rose); }

.item-edit { margin: 0 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.edit-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 10px; }
.c-name, .c-opts, .c-memo { grid-column: 1 / -1; }
.c-price { grid-column: span 5; }
.c-qty { grid-column: span 3; }
.c-unit { grid-column: span 4; }
.c-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; }
.mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 999px; background: #FFFEFC; cursor: pointer;
  font-size: 12.5px; font-weight: 600; letter-spacing: .08em; color: var(--ink); white-space: nowrap;
}
.mini.sq { width: 36px; padding: 0; }
.mini .ic { width: 15px; height: 15px; }
.mini:hover:not(:disabled) { border-color: var(--ink); }
.mini:disabled { opacity: .35; cursor: default; }
.mini.danger { margin-left: auto; color: var(--rose); border-color: color-mix(in srgb, var(--rose) 35%, #fff); }
.mini.danger:hover { background: var(--rose-tint); border-color: var(--rose); }

@keyframes itemIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0%, 35% { background: var(--gold-soft); } 100% { background: transparent; } }
@keyframes itemOut { to { opacity: 0; transform: translateX(24px); } }
.item.is-new { animation: itemIn .55s var(--ease) both; }
.item.is-new .item-head { animation: glow 1.7s ease-out; }
.item.is-leaving { animation: itemOut .22s ease-in forwards; pointer-events: none; }
.item.is-moved .item-head { animation: glow 1s ease-out; }

/* 空のとき */
.empty {
  text-align: center; padding: 30px 20px 26px;
  border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--ink-2);
}
.empty-art { width: 108px; height: auto; display: block; margin: 0 auto; }
.empty-art rect { fill: var(--row); stroke: var(--line-2); stroke-width: .8; }
.empty-art .ea-gold { stroke: var(--gold); stroke-width: 1.5; stroke-linecap: round; }
.empty-title { margin: 14px 0 4px; font-size: 15px; font-weight: 600; letter-spacing: .14em; color: var(--ink); }
.empty-text { margin: 0 0 16px; font-size: 13px; line-height: 1.9; }

/* ---------- 追加フォーム ---------- */
.add { padding: 20px 18px; display: flex; flex-direction: column; gap: 16px; }
.add-row { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, .75fr) minmax(0, .9fr); gap: 10px; }
.add-opts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.add-submit { width: 100%; height: 54px; font-size: 16px; letter-spacing: .1em; }
.add-submit .ic { stroke-width: 1.8; }
.presets {
  display: flex; align-items: center; gap: 8px; overflow-x: auto;
  margin: 0 -18px; padding: 2px 18px; scrollbar-width: none;
}
.presets::-webkit-scrollbar { display: none; }
.preset-label { flex: none; font-size: 11.5px; font-weight: 600; letter-spacing: .14em; color: var(--ink-2); }
.preset-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.8; letter-spacing: .04em; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #FFFEFC; cursor: pointer;
  font-size: 13px; font-weight: 600; letter-spacing: .06em; white-space: nowrap;
}
.chip b { font-family: var(--latin); font-size: 15px; font-weight: 600; color: var(--gold); font-variant-numeric: lining-nums; }
.chip:hover { border-color: var(--ink); }
.chip:active { transform: scale(.97); }
.privacy {
  display: flex; align-items: flex-start; justify-content: center; gap: 6px;
  margin: 6px 0 0; padding: 0 6px; font-size: 11.5px; line-height: 1.8; color: var(--muted); letter-spacing: .04em;
}
.privacy .ic { width: 13px; height: 13px; margin-top: 3px; }

/* ---------- 合計（スマホは下の帯） ---------- */
.summary {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .97);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 34px rgba(58, 50, 40, .10);
  padding-bottom: env(safe-area-inset-bottom);
}
.sum-head { display: none; }
.sum-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 20px; }
.sum-toggle {
  flex: 1; min-width: 0; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label chev" "total chev" "mini chev";
  border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
}
.sum-label { grid-area: label; display: flex; align-items: baseline; gap: 10px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .14em; white-space: nowrap; }
.sum-total {
  grid-area: total; justify-self: start;
  font-size: 32px; font-weight: 600; line-height: 1.15; white-space: nowrap; color: var(--ink);
  transform-origin: left center;
}
.sum-total.bump { animation: bump .45s var(--ease); }
@keyframes bump { 40% { transform: scale(1.05); } }
.sum-mini { grid-area: mini; font-size: 12px; color: var(--ink-2); letter-spacing: .06em; }
.sum-mini:empty { display: none; }
.sum-toggle .chev { grid-area: chev; align-self: center; transform: rotate(180deg); }
.summary.open .sum-toggle .chev { transform: none; }
.sum-doc { flex: none; height: 48px; padding: 0 20px; }
/* 足した金額のお知らせ（ボタンに見えない、文字だけの表示） */
.delta { font-family: var(--latin); font-size: 15px; font-weight: 600; color: var(--gold); letter-spacing: .02em; opacity: 0; pointer-events: none; }
.delta.neg { color: var(--rose); }
.delta.show { animation: deltaIn 1.8s var(--ease); }
@keyframes deltaIn {
  0% { opacity: 0; transform: translateY(6px); }
  12% { opacity: 1; transform: none; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
.sum-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .38s var(--ease); }
.summary.open .sum-detail { grid-template-rows: 1fr; }
.sum-inner { overflow: hidden; min-height: 0; }
.sum-scroll { max-height: 62vh; max-height: min(62dvh, 580px); overflow: auto; padding: 0 20px 18px; overscroll-behavior: contain; }

.bd { border-top: 1px solid var(--line); padding: 14px 0 12px; }
.bd-title { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; font-weight: 600; letter-spacing: .2em; color: var(--ink); }
.bd-title span:last-child { color: var(--muted); font-weight: 500; letter-spacing: .06em; }
.bd-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-size: 13.5px; color: var(--ink-2); }
.bd-row .num { font-size: 17px; color: var(--ink); }
.bd-row.total { margin-top: 6px; padding-top: 9px; border-top: 1px solid var(--line); font-weight: 600; color: var(--ink); }
.bd-row.total .num { font-size: 22px; font-weight: 600; }
.bd-row.sub { font-size: 12px; }
.bd-row.sub .num { font-size: 15px; color: var(--ink-2); }
.bd-empty { padding: 16px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.sim { margin: 4px 0 16px; padding: 14px 16px 16px; border-radius: var(--r); background: var(--row); }
.sim-head { display: flex; align-items: baseline; gap: 10px; font-size: 12px; font-weight: 600; letter-spacing: .2em; }
.sim-en { font-family: var(--latin); font-size: 15px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.sim-ctrl { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 8px; }
.sim-months { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sim-months strong { font-size: 30px; font-weight: 600; color: var(--ink); margin-right: 3px; }
.step-btn {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-2); background: #FFFEFC; color: var(--ink); font-size: 18px; line-height: 1;
}
.step-btn:hover { border-color: var(--ink); }
.sim-quick { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.sim-quick button {
  height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: #FFFEFC; color: var(--ink-2); font-size: 12px; font-weight: 600; letter-spacing: .08em;
}
.sim-quick button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sim-result { text-align: center; font-size: 12px; color: var(--ink-2); margin-bottom: 12px; letter-spacing: .04em; }
.sim-result strong { display: block; margin-top: 2px; font-family: var(--latin); font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: .02em; font-variant-numeric: lining-nums tabular-nums; }
.sim .chk { font-size: 12.5px; }
.sum-actions { display: flex; flex-direction: column; gap: 8px; }
.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(58, 50, 40, .32); opacity: 0; pointer-events: none; transition: opacity .25s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

@media (min-width: 900px) {
  .summary {
    position: relative; border: 1px solid var(--line); border-radius: 14px;
    background: var(--paper); box-shadow: var(--shadow-2); padding: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .sum-head {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 24px 24px 16px; margin: 0 24px; border-bottom: 1px solid var(--line);
  }
  .sum-head-en { font-family: var(--latin); font-size: 26px; font-weight: 500; letter-spacing: .3em; padding-left: .3em; text-transform: uppercase; line-height: 1.2; }
  .sum-head-ja { font-size: 11.5px; font-weight: 600; letter-spacing: .3em; color: var(--ink-2); padding-left: .3em; }
  .sum-bar { padding: 18px 24px 8px; }
  .sum-toggle { cursor: default; pointer-events: none; }
  .sum-toggle .chev, .sum-doc { display: none; }
  .sum-total { font-size: 40px; }
  .sum-detail { grid-template-rows: 1fr; }
  .sum-scroll { max-height: none; overflow: visible; padding: 0 24px 24px; }
  .scrim { display: none; }
}

/* ---------- 下から出るシート（一覧・設定） ---------- */
dialog.sheet {
  width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: 18px 18px 0 0; background: var(--bg); color: var(--ink);
  box-shadow: var(--shadow-2); overflow: hidden; flex-direction: column;
}
dialog.sheet[open] { display: flex; animation: sheetUp .34s var(--ease); }
dialog::backdrop { background: rgba(58, 50, 40, .38); }
@keyframes sheetUp { from { transform: translateY(48px); opacity: 0; } }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; max-width: 640px; max-height: 86vh; border-radius: 16px; }
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 10px 12px 22px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; display: flex; align-items: baseline; gap: 12px; font-size: 15px; font-weight: 600; letter-spacing: .2em; }
.sheet-en { font-family: var(--latin); font-size: 22px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.sheet-body {
  overflow: auto; padding: 18px; padding-bottom: calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain;
}
.sheet-note { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

.est-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.est { display: flex; align-items: stretch; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.est.current { border-color: var(--ink); }
.est-open {
  flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px;
  padding: 14px 16px; border: 0; background: none; text-align: left; cursor: pointer;
}
.est-open:hover { background: var(--tint); }
.est-name { font-weight: 600; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-meta { grid-column: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-amt { grid-column: 2; grid-row: 1 / 3; align-self: center; font-family: var(--latin); font-size: 20px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.est-amt small { font-family: var(--serif); font-size: 11px; color: var(--muted); }
.badge-now { margin-left: 8px; font-size: 11px; font-weight: 600; letter-spacing: .12em; color: var(--gold); }
.est-acts { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.est-acts button { flex: 1; min-width: 60px; padding: 0 12px; border: 0; background: none; cursor: pointer; font-size: 12.5px; font-weight: 600; letter-spacing: .1em; color: var(--ink); }
.est-acts button + button { border-top: 1px solid var(--line); }
.est-acts button:hover { background: var(--tint); }
.est-acts .del { color: var(--rose); }
.est-acts .del:hover { background: var(--rose-tint); }
.est-empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13.5px; }

.set-sec { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.set-sec h3 { margin: 0 0 2px; font-size: 14.5px; font-weight: 600; letter-spacing: .12em; }
.set-sec .desc { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.stamp-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stamp-preview {
  width: 64px; height: 64px; flex: none; display: grid; place-items: center; overflow: hidden;
  border: 1px dashed var(--line-2); border-radius: 8px; background: #FFFEFC; font-size: 11px; color: var(--muted);
}
.stamp-preview img { max-width: 100%; max-height: 100%; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.swatches { display: flex; gap: 14px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; padding: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.swatch i { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line-2); display: block; }
.swatch[aria-pressed=true] i { box-shadow: 0 0 0 1.5px var(--ink); }
.swatch[aria-pressed=true] { color: var(--ink); }
.swatch.custom i { background: conic-gradient(#c97a6d, #d9b26a, #8fae8b, #7d95b5, #a589b8, #c97a6d); position: relative; }
.swatch.custom input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preset-manage { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.preset-manage li { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.preset-manage .pm-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-manage .pm-amt { font-family: var(--latin); font-size: 17px; font-weight: 600; color: var(--gold); white-space: nowrap; }
.preset-manage .pm-empty { justify-content: center; color: var(--muted); font-size: 13px; border-style: dashed; padding: 10px; }

/* ---------- お知らせ ---------- */
.toast {
  position: fixed; inset: auto; left: 50%; bottom: calc(118px + env(safe-area-inset-bottom));
  margin: 0; border: 0; overflow: visible;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); width: max-content;
  padding: 10px 10px 10px 20px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 600; letter-spacing: .06em;
  box-shadow: 0 12px 32px rgba(58, 50, 40, .28);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s var(--ease);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast span { padding: 4px 0; }
.toast button { flex: none; border: 1px solid rgba(250, 246, 241, .35); border-radius: 999px; padding: 6px 14px; background: transparent; color: var(--gold-soft); font-weight: 600; letter-spacing: .1em; cursor: pointer; }
@media (min-width: 900px) { .toast { bottom: 36px; } }

/* ---------- 見積書プレビュー ---------- */
.preview { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #E9E2D8; }
.pv-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--ink); color: var(--bg);
}
.pv-title { flex: 1; text-align: center; font-weight: 600; font-size: 15px; letter-spacing: .4em; padding-left: .4em; }
.btn.ghost-light { height: 40px; padding: 0 14px 0 10px; font-size: 13.5px; background: transparent; border-color: rgba(250, 246, 241, .35); color: var(--bg); }
.btn.light { height: 40px; padding: 0 16px; font-size: 13.5px; background: var(--bg); color: var(--ink); }
.pv-hint { margin: 0; padding: 9px 16px; font-size: 12px; line-height: 1.7; color: var(--ink-2); text-align: center; background: rgba(255, 255, 255, .5); border-bottom: 1px solid rgba(58, 50, 40, .08); }
.pv-hint button { border: 0; background: none; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0 2px; font-size: inherit; }
.pv-stage { flex: 1; overflow: auto; padding: 18px 16px 28px; -webkit-overflow-scrolling: touch; }
.pv-sizer { position: relative; margin: 0 auto; }

/* 見積書の本体（A4） */
.doc {
  position: absolute; top: 0; left: 0;
  width: 210mm; min-height: 297mm;
  padding: 12mm 15mm 11mm;
  background: #fff; color: #2E2823;
  font-family: var(--serif); font-size: 9.3pt; font-weight: 500; line-height: 1.55; letter-spacing: .03em;
  box-shadow: 0 12px 40px rgba(58, 50, 40, .18);
  transform-origin: top left;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.doc-head { text-align: center; padding-bottom: 3mm; margin-bottom: 2mm; border-bottom: 3px double var(--deep); }
.doc-en { margin: 0; font-family: var(--latin); font-size: 10pt; font-weight: 600; letter-spacing: .5em; padding-left: .5em; color: var(--gold); }
.doc-title { margin: .5mm 0 0; font-family: var(--serif); font-size: 20pt; font-weight: 600; letter-spacing: .7em; padding-left: .7em; line-height: 1.3; color: #1F1A16; }
.doc-meta { margin: 0 0 5mm; display: flex; justify-content: flex-end; gap: 6mm; font-size: 8.8pt; color: #5E5347; }
.doc-meta b { font-weight: 500; color: #2E2823; margin-left: 2mm; }
.doc-top { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10mm; margin-bottom: 2mm; }
.to-name { display: flex; align-items: baseline; justify-content: space-between; gap: 4mm; padding-bottom: 1.5mm; border-bottom: 1px solid #2E2823; font-size: 14.5pt; font-weight: 600; line-height: 1.4; letter-spacing: .06em; }
.to-name .hon { flex: none; font-size: 11pt; }
.doc-lead { margin: 2.5mm 0; font-size: 9.3pt; }
.doc-cond { margin: 0 0 4mm; display: grid; grid-template-columns: 17mm minmax(0, 1fr); gap: .8mm 0; font-size: 9.3pt; }
.doc-cond dt { color: #7A6E61; }
.doc-cond dd { margin: 0; }
.doc-total {
  display: flex; align-items: center; justify-content: space-between; gap: 4mm;
  padding: 2.4mm 4mm; background: #F7F2EB; border-top: 1px solid var(--deep); border-bottom: 1px solid var(--deep);
}
.doc-total span { font-size: 10pt; font-weight: 600; letter-spacing: .1em; }
.doc-total strong { font-family: var(--latin); font-size: 22pt; font-weight: 600; letter-spacing: .02em; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.doc-total-sub { margin-top: 1.8mm; text-align: right; font-size: 9.3pt; }
.doc-total-sub b { font-family: var(--latin); font-size: 12.5pt; font-weight: 600; font-variant-numeric: lining-nums; }
.doc-from { position: relative; padding-top: 1mm; font-size: 8.8pt; line-height: 1.8; }
.from-name { margin-bottom: 1mm; font-size: 12pt; font-weight: 600; line-height: 1.45; padding-right: 16mm; letter-spacing: .06em; }
.doc-from .stamp { position: absolute; right: 0; top: -1mm; width: 21mm; height: 21mm; object-fit: contain; mix-blend-mode: multiply; }
.doc-sec { margin-top: 5mm; }
.doc-sec h2 { margin: 0 0 2mm; font-size: 10.5pt; font-weight: 600; letter-spacing: .2em; line-height: 1.3; display: flex; align-items: center; gap: 2.5mm; }
.doc-sec h2::before { content: ""; width: 6mm; height: 1px; background: var(--gold); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 9.2pt; }
.doc-table col.w-no { width: 9mm; }
.doc-table col.w-qty { width: 20mm; }
.doc-table col.w-price { width: 25mm; }
.doc-table col.w-amt { width: 28mm; }
.doc-table th { padding: 1.8mm 2.2mm; background: #F4EEE6; color: #2E2823; font-weight: 600; font-size: 8.8pt; letter-spacing: .2em; text-align: center; border-top: 1px solid var(--deep); border-bottom: 1px solid #CFC3B4; }
.doc-table td { padding: 1.7mm 2.2mm; border-bottom: 1px solid #E8E0D5; vertical-align: top; }
.doc-table tr { break-inside: avoid; }
.doc-table td.c { text-align: center; color: #A88B57; font-family: var(--latin); font-weight: 600; font-size: 10pt; }
.doc-table td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table td.q { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table .memo { display: block; margin-top: .4mm; font-size: 7.8pt; color: #7A6E61; white-space: pre-wrap; }
.doc-table .neg { color: var(--rose); }
.doc-table tbody.sums td { padding: 1mm 2.2mm; border: 0; }
.doc-table tbody.sums tr:first-child td { padding-top: 2mm; }
.doc-table tbody.sums tr.grand td { padding-top: 1.6mm; }
.doc-table tbody.sums .fl { text-align: right; color: #5E5347; }
.doc-table tbody.sums tr.grand td { font-weight: 600; font-size: 10.5pt; }
.doc-table tbody.sums tr.grand td.fl, .doc-table tbody.sums tr.grand td.n { border-top: 1px solid var(--deep); }
.doc-table tbody.sums tr.note td { font-size: 8.5pt; color: #7A6E61; }
.doc-sim {
  margin-top: 4mm; padding: 2.2mm 4mm; border: 1px solid #E0D6C9; background: #FBF8F4;
  display: flex; align-items: center; justify-content: space-between; gap: 4mm; flex-wrap: wrap; font-size: 9pt;
}
.doc-sim b { font-family: var(--latin); font-size: 12.5pt; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.doc-note { margin-top: 4.5mm; break-inside: avoid; }
.doc-note h2 { margin: 0 0 1.5mm; font-size: 9.5pt; font-weight: 600; letter-spacing: .2em; color: #5E5347; }
.doc-note .box { padding: 2.8mm 4mm; border: 1px solid #E0D6C9; white-space: pre-wrap; font-size: 8.8pt; line-height: 1.8; }
.doc-end { margin-top: 3.5mm; text-align: right; font-size: 9pt; letter-spacing: .2em; color: #5E5347; }

/* ---------- 印刷・PDF ---------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#preview) { display: none !important; }
  #preview { display: block !important; position: static; background: #fff; }
  .pv-bar, .pv-hint { display: none !important; }
  .pv-stage { padding: 0; overflow: visible; }
  .pv-sizer { width: auto !important; height: auto !important; }
  .doc {
    position: static; transform: none !important; box-shadow: none;
    min-height: 0; margin: 0;
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* まわるのロゴ（リボンの印） */
.brand-mark { width: 40px; height: 40px; flex: none; object-fit: contain; display: block; }
