:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #111827;
  --primary-hover: #374151;
  --error: #b91c1c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
}
.brand-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
}
.topnav { display: flex; align-items: center; gap: 12px; }
.user-email { font-size: 13px; color: var(--muted); }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 20px; margin: 0; }

.property-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-toolbar {
  margin-bottom: 12px;
}
#property-search {
  font: inherit;
  width: 100%;
  max-width: 480px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
#property-search:focus { outline: none; border-color: var(--primary); }

.property-count {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

/* 簡易リスト 1行 */
.property-row {
  display: grid;
  grid-template-columns: 28px 1fr 1.4fr 100px 32px 180px 110px 60px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s;
}
.property-row:hover { border-color: var(--primary); }
.property-row.is-featured { background: linear-gradient(90deg, #fff7ed 0%, #fff 30%); }
.property-row.is-selected { background: linear-gradient(90deg, #eff6ff 0%, #fff 60%); border-color: #93c5fd; }
.property-row.is-featured.is-selected { background: linear-gradient(90deg, #eff6ff 0%, #fff7ed 50%, #fff 100%); }

.property-row-check {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.property-row-check input { width: 16px; height: 16px; cursor: pointer; margin: 0; }

.property-row-title {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s, color 0.15s;
}
.property-row-title:hover { color: var(--primary); text-decoration-color: var(--primary); }

.property-row-meta {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.property-row-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}
.property-row-price .unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}

.featured-star {
  font-size: 20px;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.featured-star:hover { color: #fbbf24; border-color: #fbbf24; }
.featured-star.on { color: #fbbf24; background: #fffbeb; border-color: #fbbf24; }

.property-row-status {
  display: flex;
  gap: 4px;
}
.status-radio {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  user-select: none;
}
.status-radio input { margin: 0; cursor: pointer; }
.status-radio.on-pub { background: #dcfce7; border-color: #86efac; color: #166534; }
.status-radio.on-draft { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

/* モバイル: 行を縦に */
@media (max-width: 720px) {
  .property-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .property-row-price { text-align: left; }
  .property-row-status { justify-self: start; }
  .property-row-check { justify-self: start; }
}

.section-head-actions { display: flex; gap: 8px; align-items: center; }

/* SUUMO バッジ */
.suumo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.suumo-badge.suumo-synced { background: #dcfce7; color: #166534; border-color: #86efac; }
.suumo-badge.suumo-pending { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.suumo-badge.suumo-failed { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.suumo-badge.suumo-not_synced { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.suumo-badge.suumo-unknown { background: #fef9c3; color: #854d0e; border-color: #fde68a; }

/* SUUMO 一括送信バー */
.suumo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
}
.suumo-bar-count { font-size: 13px; color: #1e40af; font-weight: 600; }
.suumo-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.form-actions-spacer { flex: 1; }

/* toast */
.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast-success { background: #166534; }
.toast-error { background: #b91c1c; }
.toast-info { background: #1e40af; }
.toast-leave { opacity: 0; transition: opacity 0.6s; }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 旧カード形式 (残置・互換用) */
.property-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.property-card h3 { margin: 0 0 8px; font-size: 16px; flex: 1; }

.property-thumb {
  aspect-ratio: 4 / 3;
  background: #f3f4f6;
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.property-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-photo { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }

.property-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.status-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge.published { background: #dcfce7; color: #166534; }
.status-badge.draft { background: #fef3c7; color: #92400e; }

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn-sm {
  padding: 4px 10px !important;
  font-size: 12px;
}

.btn-danger {
  font: inherit;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  background: transparent;
  color: var(--error);
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-danger:hover:not(:disabled) { background: #fef2f2; border-color: #fecaca; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary, .btn-ghost {
  font: inherit;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
a.manual-link { text-decoration: none; display: inline-block; }

.muted { color: var(--muted); }
.error { color: var(--error); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: min(380px, 92vw);
  text-align: center;
}
.login-card .brand { display: block; margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; padding: 12px; margin-top: 8px; }
.login-card .reset-title { font-size: 18px; margin: 0 0 8px; }
.reset-done {
  margin-top: 16px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 8px;
}
.reset-done p { margin: 0 0 6px; }
.reset-done p:last-child { margin-bottom: 0; }

/* --- hidden 属性の恒久ガード --- */
/* class 側の display 指定 (.pw-modal の grid / .suumo-bar の flex / .event-fields の
   grid 等) が UA の [hidden]{display:none} を上書きして「hidden なのに表示される」
   事故が起きたため、hidden 属性を全要素で最優先にする。 */
[hidden] { display: none !important; }

/* --- ログイン中のパスワード変更モーダル --- */
.pw-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 16px;
}
.pw-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(380px, 92vw);
}
.pw-modal-card h3 { margin: 0 0 8px; }
.pw-modal-card .btn-primary { width: 100%; padding: 10px; margin-top: 8px; }
.pw-modal-card .pw-cancel { width: 100%; margin-top: 8px; }

/* --- Netlify Identity Widget が injection する空 iframe を抑止 --- */
/* widget の modal UI が壊れていて中身レンダリングされないのに iframe だけ */
/* viewport を覆って (position: fixed; 100%) クリックを intercept するため. */
/* gotrue (API client) のみ使う方針なので iframe を完全に消して問題ない. */
iframe#netlify-identity-widget {
  display: none !important;
}

/* --- 自前 auth form (招待受諾 / リカバリ / ログイン) --- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-top: 16px;
}
.auth-form label {
  font-size: 13px;
  color: var(--muted, #555);
  font-weight: 500;
}
.auth-form input[type="email"],
.auth-form input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 4px;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
}
.auth-form .btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
}
.auth-form .error {
  font-size: 13px;
  margin-top: 8px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  margin: 48px auto;
  box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 8px; font-size: 18px; }
.auth-card .muted { font-size: 13px; margin: 0 0 16px; }
.small { font-size: 12px; }

/* --- form panel (M2: 物件追加) --- */
.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 24px;
  box-shadow: var(--shadow);
}

#property-form { display: grid; gap: 16px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}

#property-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
#property-form input[type="text"],
#property-form input[type="number"],
#property-form input[type="time"],
#property-form input:not([type]),
#property-form select,
#property-form textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
#property-form input:focus,
#property-form select:focus,
#property-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* --- セクション見出し / SUUMO必須マーク --- */
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.form-section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-required-note { font-size: 12px; color: var(--muted); margin: 0; }
.req-suumo { color: #b91c1c; font-weight: 700; }

.char-counter { font-size: 11px; color: var(--muted); text-align: right; }
.catch-ai-actions { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.form-check-inline {
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  color: var(--text) !important;
  font-size: 14px !important;
  margin-bottom: 10px;
}
.event-fields { display: grid; gap: 12px; }

/* --- 画像 並べ替え --- */
.image-tile { cursor: grab; }
.image-tile.dragging { opacity: 0.4; }
.image-tile.drag-over { outline: 2px dashed var(--primary); outline-offset: 2px; }
.image-order-tag {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(17, 24, 39, 0.78);
  color: #fff;
  font-size: 10px;
  min-width: 18px;
  text-align: center;
  padding: 1px 5px;
  border-radius: 10px;
}

.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.form-fieldset legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.form-fieldset label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
}

/* --- 追加ボタンで増える行 (その他路線 / 自由バッジ) --- */
.repeat-list { display: grid; gap: 8px; width: 100%; }
.repeat-list:not(:empty) { margin-top: 10px; }
.repeat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 8px 12px;
  align-items: end;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.repeat-row .repeat-remove { align-self: end; }
.repeat-actions { margin-top: 8px; width: 100%; }
/* 自由バッジは1行1入力なので伸ばす */
.repeat-row.repeat-row-badge { grid-template-columns: 1fr auto; }
.form-fieldset .badge-free { flex-direction: row; align-items: center; gap: 6px; }
.form-fieldset .badge-free input { max-width: 200px; }
.form-fieldset .muted.small { flex-basis: 100%; margin: 0; }

.form-textarea { color: var(--muted); font-size: 13px; }
.form-textarea textarea { width: 100%; resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.success { color: #166534; }

/* --- 画像セクション --- */
.images-fieldset { display: block; }
.images-fieldset .form-hint { margin: 4px 0 12px; font-size: 12px; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.image-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #f3f4f6;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.78);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-remove:hover { background: rgba(220, 38, 38, 0.92); }
.image-main-tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(17, 24, 39, 0.78);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.image-pending-tag {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(234, 179, 8, 0.95);
  color: #422006;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.image-add {
  display: flex;
  align-items: center;
  gap: 12px;
}
.image-add-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.small { font-size: 12px; }

/* --- マイソク AI 自動入力 --- */
.form-ai-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ai-import-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.ai-import-btn:has(input:disabled) { opacity: 0.5; cursor: wait; }
.success-text { color: #166534; }

/* --- サイトに反映 (デプロイ節約運用) --- */
.deploy-status-text {
  white-space: nowrap;
}
/* 未反映の変更があるときはボタンを目立たせて押し忘れを防ぐ */
#deploy-site-btn.deploy-attention {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 600;
  animation: deploy-pulse 2s ease-in-out infinite;
}
@keyframes deploy-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
