:root {
  --bg: #eef1ed;
  --surface: #ffffff;
  --ink: #1f2a27;
  --muted: #66726d;
  --line: #e3e7e2;
  --line-strong: #d3d9d2;
  --a: #2e6a55;          /* 左側の色 */
  --b: #34508f;          /* 右側の色 */
  --none: #a3aca8;

  /* 有利な側のハイライト */
  --hl-bg: #fff3c2;
  --hl-edge: #e9b824;
  --hl-ink: #5c4500;

  /* 内見申し込みボタン */
  --cta: #d9480f;

  --spine: 72px;
  --gap: 10px;
  --pad: 16px;
  --block-pad: 14px;
  --radius: 12px;
  --radius-s: 8px;
  --bar-h: 84px;

  --fs-xs: 11px;
  --fs-s: 12px;
  --fs-m: 14px;
  --fs-l: 18px;
  --fs-xl: 22px;
}

@media (min-width: 760px) {
  :root {
    --spine: 140px;
    --gap: 24px;
    --pad: 32px;
    --block-pad: 28px;
    --radius: 16px;
    --bar-h: 92px;
    --fs-xs: 12px;
    --fs-s: 13px;
    --fs-m: 16px;
    --fs-l: 22px;
    --fs-xl: 30px;
  }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: var(--fs-m);
  line-height: 1.7;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 24px);
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(238, 241, 237, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-strong);
}
.topbar__inner {
  max-width: 1120px; margin: 0 auto;
  padding: 14px var(--pad) 10px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
}
.brand { margin: 0; font-size: var(--fs-m); font-weight: 700; letter-spacing: 0.04em; }

.conditions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 3px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: var(--fs-s);
}
.chip__label { color: var(--muted); font-size: var(--fs-xs); }
.chip__value { font-weight: 500; }

.progress { max-width: 1120px; margin: 0 auto; padding: 2px var(--pad) 14px; }
.progress__text { display: flex; justify-content: space-between; font-size: var(--fs-s); margin-bottom: 6px; }
.progress__rest { color: var(--muted); }
.progress__track { height: 4px; background: var(--line-strong); border-radius: 2px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--ink); transition: width 0.3s ease; }

/* ---------- 比較ボード ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 20px var(--pad) 40px; }

.lead { margin: 0 0 20px; font-size: var(--fs-s); color: var(--muted); line-height: 1.8; }

.board { display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 760px) { .board { gap: 28px; } }

/* セクション */
.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--block-pad) calc(var(--block-pad) - 4px);
}
.block__title {
  margin: 0 0 8px;
  padding: 0 4px 10px;
  font-size: var(--fs-m); font-weight: 700;
  border-bottom: 2px solid var(--ink);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--spine) minmax(0, 1fr);
  column-gap: var(--gap);
  align-items: stretch;
}
.block__rows .row + .row { border-top: 1px solid var(--line); }

.cell {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (min-width: 760px) { .cell { margin: 8px 0; padding: 10px 16px; } }
.cell--left { text-align: right; align-items: flex-end; }
.cell--right { text-align: left; align-items: flex-start; }

.spine {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 8px 0;
}
.spine__label { font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }

/* 有利な側を指す印 */
.spine__mark { display: block; width: 24px; height: 8px; position: relative; }
.spine__mark::before {
  content: ""; position: absolute; top: 3px; left: 3px; right: 3px; height: 2px; border-radius: 1px;
  background: var(--hl-edge);
}
.spine__mark::after {
  content: ""; position: absolute; top: 0; width: 0; height: 0;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.spine__mark--left::after { left: 0; border-right: 7px solid var(--hl-edge); }
.spine__mark--right::after { right: 0; border-left: 7px solid var(--hl-edge); }

.val { font-size: var(--fs-m); line-height: 1.45; }
.val--sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* 有利な側のハイライト */
.cell.is-better { background: var(--hl-bg); color: var(--hl-ink); }
.cell.is-better .val:first-child { font-weight: 700; }
.cell--left.is-better { box-shadow: inset -3px 0 0 var(--hl-edge); }
.cell--right.is-better { box-shadow: inset 3px 0 0 var(--hl-edge); }
.cell.is-better .val--sub { color: #8a7230; }
.cell.is-none { color: var(--none); }

.row--strong .val:first-child { font-size: var(--fs-l); }

/* 概要セクション(写真・名前・家賃) */
.block--summary { padding-top: var(--block-pad); }
.row--photo .cell { margin: 0; padding: 0; border-radius: 0; }
.photo {
  position: relative; width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-s); overflow: hidden;
  background: var(--line);
}
@media (min-width: 760px) {
  .row--photo .photo { aspect-ratio: 16 / 10; max-height: 320px; }
}
.cell--left .photo { box-shadow: 0 0 0 3px var(--a); }
.cell--right .photo { box-shadow: 0 0 0 3px var(--b); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo img[data-kind="floorplan"] { object-fit: contain; background: #fff; }

/* 写真の種類の切り替え(左右連動) */
.kinds {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px; padding: 4px; margin: 0 auto 16px; max-width: 440px;
  background: var(--bg); border-radius: 999px;
}
.kinds__btn {
  border: 0; background: transparent; border-radius: 999px; cursor: pointer;
  font-size: var(--fs-s); padding: 6px 4px; min-height: 36px; color: var(--muted);
}
.kinds__btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(31, 42, 39, 0.15); }
@media (min-width: 760px) { .kinds { margin-bottom: 22px; } }
.streak {
  position: absolute; top: 8px; left: 8px;
  background: var(--ink); color: #fff;
  font-size: var(--fs-xs); padding: 2px 10px; border-radius: 999px;
}

.row--head .cell {
  margin: 14px 0 0; padding: 0 2px;
  text-align: left; align-items: flex-start; justify-content: flex-start;
}
.head__name, .head__rent, .head__sub, .head__note { margin: 0; }
.head__name { font-weight: 700; font-size: var(--fs-m); line-height: 1.4; }
.cell--left .head__name { color: var(--a); }
.cell--right .head__name { color: var(--b); }
.head__rent { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; margin-top: 6px; font-feature-settings: "palt"; }
.head__sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; line-height: 1.6; }
.head__note {
  font-size: var(--fs-s); margin-top: 12px; line-height: 1.7;
  padding-top: 12px; border-top: 1px dashed var(--line-strong); width: 100%;
}

.row--feature .cell { margin: 4px 0; padding-top: 6px; padding-bottom: 6px; }

/* 入れ替わった側の表示 */
.cell.is-entering { animation: enter 0.35s ease both; }
@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 選択バー ---------- */
.choicebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -4px 16px rgba(31, 42, 39, 0.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.choicebar[hidden] { display: none; }
.choicebar__inner {
  max-width: 1120px; margin: 0 auto; height: var(--bar-h);
  padding: 14px calc(var(--pad) + var(--block-pad) - 4px);
  display: grid; grid-template-columns: minmax(0, 1fr) var(--spine) minmax(0, 1fr);
  column-gap: var(--gap); align-items: stretch;
}
.choose {
  border: 0; border-radius: var(--radius-s); cursor: pointer;
  color: #fff; font-weight: 700; font-size: var(--fs-m); letter-spacing: 0.1em;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.choose--a { background: var(--a); }
.choose--b { background: var(--b); }
.choose:hover { filter: brightness(1.08); }
.choose:active { transform: scale(0.98); }
.undo {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-s);
  font-size: var(--fs-xs); color: var(--muted); cursor: pointer; padding: 0 4px; line-height: 1.3;
}
.undo:disabled { opacity: 0.4; cursor: default; }

/* ---------- 結果画面(物件詳細) ---------- */
.result[hidden] { display: none; }
.result { display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 760px) { .result { gap: 28px; } }

.detail { padding: var(--block-pad); }
.detail__kicker { margin: 0; font-size: var(--fs-s); color: var(--a); font-weight: 700; }
.detail__name { margin: 4px 0 0; font-size: var(--fs-xl); line-height: 1.3; }
.detail__address { margin: 6px 0 0; font-size: var(--fs-s); color: var(--muted); }
.detail__media { margin-top: 20px; }
.detail__photo { aspect-ratio: 4 / 3; max-width: 760px; margin: 0 auto; }
.detail__price { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.detail__rent, .detail__fee { margin: 0; }
.detail__rent { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; font-feature-settings: "palt"; }
.detail__fee { font-size: var(--fs-s); color: var(--muted); }
.detail__note { margin: 16px 0 0; padding-top: 16px; border-top: 1px dashed var(--line-strong); font-size: var(--fs-m); }
.detail__record { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--muted); }

.spec { margin: 0; }
.spec__row {
  display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 12px;
  padding: 12px 4px; border-top: 1px solid var(--line);
}
.spec__row:first-child { border-top: 0; }
.spec__label { font-size: var(--fs-s); color: var(--muted); padding-top: 2px; }
.spec__value { margin: 0; display: flex; flex-direction: column; }
.spec__value.is-none { color: var(--none); }
@media (min-width: 760px) {
  .spec { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; }
  .spec__row:nth-child(2) { border-top: 0; }
}

.result__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-s);
  padding: 12px 20px; cursor: pointer; font-weight: 500; font-size: var(--fs-s);
}

/* ---------- 内見申し込みフッター ---------- */
.resultbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -6px 20px rgba(31, 42, 39, 0.1);
  padding-bottom: env(safe-area-inset-bottom);
}
.resultbar[hidden] { display: none; }
.resultbar__inner {
  max-width: 1120px; margin: 0 auto; min-height: var(--bar-h);
  padding: 12px var(--pad);
  display: flex; align-items: center; gap: 16px;
}
.resultbar__info { flex: 1; min-width: 0; }
.resultbar__name, .resultbar__rent { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resultbar__name { font-size: var(--fs-s); font-weight: 700; }
.resultbar__rent { font-size: var(--fs-xs); color: var(--muted); }

.visit-btn {
  border: 0; border-radius: var(--radius-s); cursor: pointer;
  background: var(--cta); color: #fff;
  font-weight: 700; font-size: var(--fs-l); letter-spacing: 0.06em;
  padding: 14px 28px; min-height: 56px;
  box-shadow: 0 4px 12px rgba(201, 66, 12, 0.3);
  transition: transform 0.1s ease, filter 0.15s ease;
  flex-shrink: 0;
}
.visit-btn:hover { filter: brightness(1.06); }
.visit-btn:active { transform: scale(0.98); }
@media (max-width: 759px) {
  .resultbar__inner .visit-btn { flex: 1.4; padding: 14px 12px; font-size: var(--fs-l); }
}

/* ---------- 内見申し込みダイアログ ---------- */
.visit {
  border: 0; border-radius: var(--radius); padding: 0;
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(31, 42, 39, 0.3);
}
.visit::backdrop { background: rgba(31, 42, 39, 0.45); }
.visit__form, .visit__done { padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 760px) { .visit__form, .visit__done { padding: 32px; } }
.visit__title { margin: 0; font-size: var(--fs-l); }
.visit__property { margin: -8px 0 0; font-weight: 700; color: var(--a); }
.visit__demo { margin: 0; font-size: var(--fs-xs); color: var(--muted); background: var(--bg); padding: 8px 12px; border-radius: var(--radius-s); }
.visit__done p { margin: 0; }
.visit__actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.visit__actions .visit-btn { font-size: var(--fs-m); min-height: 48px; padding: 10px 24px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-s); font-weight: 500; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 10px 12px; background: #fff; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.log summary { cursor: pointer; font-weight: 700; font-size: var(--fs-m); }
.log__list { margin: 14px 0 0; padding-left: 1.8em; font-size: var(--fs-s); }
.log__list li { padding: 4px 0; }
.log__win { font-weight: 700; }
.log__vs { color: var(--muted); margin: 0 6px; }
.log__lose { color: var(--muted); }
.log__lose::before { content: "(相手: "; }
.log__lose::after { content: ")"; }

.result__actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-s);
  padding: 14px 24px; cursor: pointer; font-weight: 500;
}
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }

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