/* ===========================
   Listing Compare - styles
   Base tone matches the CobbleWorks palette (Terracotta & Cream).
   =========================== */

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

/* display: flex などが UA の [hidden] を上書きしてしまうので、こちらを強くする */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;

  --bg: #FAF4EC;
  --card: #FFFFFF;
  --border: #EDE2D4;
  --divider: #F4EBDF;
  --ink: #3D3229;
  --text-2: #6B5F51;
  --muted: #8C7F70;
  --faint: #A2968A;

  --accent: #D9704C;
  --accent-dark: #BF5B39;
  --accent-tint: #FBEDE7;
  --success: #2E9E54;
  --success-tint: #EAF6EE;
  --danger: #C0392B;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 4px rgba(61, 50, 41, 0.08);
}

body {
  margin: 0;
  padding: 24px 16px 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

header,
main {
  max-width: 720px;
  margin: 0 auto;
}

header {
  margin-bottom: 24px;
}

/* 読み上げ専用 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* -----------------------
   Header
   ----------------------- */

h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.title-icon {
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--accent);
}

.title-accent {
  color: var(--accent);
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* -----------------------
   Card
   ----------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 20px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.card > .card-title {
  margin-bottom: 16px;
}

/* -----------------------
   Form
   ----------------------- */

.field {
  margin-bottom: 16px;
}

/* 横並びの2項目は、行のほうで下の間隔を持つ */
.field-row .field {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.req {
  color: var(--muted);
  font-weight: 400;
}

input[type="text"],
input[type="url"],
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* iOS のズームを防ぐ */
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
.table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #FEF6F4;
}

.hint {
  margin: 6px 0 0;
  color: var(--faint);
  font-size: 13px;
}

.error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.error::before {
  content: "!";
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.field-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

/* -----------------------
   Buttons
   ----------------------- */

.btn-primary,
.btn-ghost,
.btn-small {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  background: #fff;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-small:hover {
  background: var(--bg);
}

.btn-small.is-armed {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* -----------------------
   Section head
   ----------------------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
}

.count {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* -----------------------
   Empty state
   ----------------------- */

.empty {
  text-align: center;
  padding: 28px 20px;
}

.empty-title {
  margin: 0 0 6px;
  font-weight: 700;
}

.empty-body {
  margin: 0 auto;
  max-width: 34em;
  color: var(--muted);
  font-size: 15px;
}

/* -----------------------
   Comparison table
   ----------------------- */

.table-wrap {
  /* 表の中の読み上げ専用テキスト(position: absolute)がページ全体を
     横に広げてしまわないよう、この枠を基準にして閉じ込める */
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.compare {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.compare th,
.compare td {
  text-align: left;
  vertical-align: top;
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  font-size: 15px;
}

.compare tr:last-child th,
.compare tr:last-child td {
  border-bottom: 0;
}

/* 左端の項目名を固定する */
.rowhead {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 92px;
  min-width: 92px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compare td,
.compare th.col-head {
  min-width: 176px;
}

.col-head {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.col-head .col-name {
  display: block;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--success-tint);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.badge-inline {
  margin-top: 0;
  vertical-align: baseline;
}

.rent-value {
  font-size: 17px;
  font-weight: 700;
}

.rent-per {
  color: var(--faint);
  font-size: 12px;
  font-weight: 400;
}

.is-lowest .rent-value {
  color: var(--success);
}

.notes-cell {
  white-space: pre-wrap;
  color: var(--text-2);
  font-size: 14px;
}

.blank {
  color: var(--faint);
}

.listing-link {
  color: var(--accent-dark);
  font-size: 14px;
  word-break: break-word;
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scroll-hint {
  margin: 10px 4px 20px;
  color: var(--faint);
  font-size: 13px;
}

/* -----------------------
   How to use
   ----------------------- */

.how-to h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.how-to-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-to-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--text-2);
  font-size: 15px;
}

.how-to-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.how-to-icon svg {
  width: 16px;
  height: 16px;
}

.how-to-note {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: 13px;
}

/* -----------------------
   Toast
   ----------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(61, 50, 41, 0.25);
  z-index: 20;
}

/* -----------------------
   Wider screens
   ----------------------- */

@media (min-width: 620px) {
  body {
    padding: 40px 20px 8px;
  }

  .card {
    padding: 24px 22px;
  }

  .field-row {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 32px;
  }

  .rowhead {
    width: 120px;
    min-width: 120px;
  }
}
