/* ═══ hAIchi v0.1.1 — pAIr Mind デザインテーマ ═══════════════════════════ */
/* フォントは index.html の <link> で非ブロッキング読込 (オフライン時は
   システムフォントにフォールバック) */

:root {
  --brand: #028DAE;
  --brand-dark: #015f78;
  --brand-light: rgba(2,141,174,0.10);
  --brand-line: rgba(2,141,174,0.04);
  --ink: #1a1a2e;
  --ink-2: #555;
  --ink-3: #888;
  --card: #ffffff;
  --bg: #f9fbfc;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #ca8a04;
  --radius: 14px;
  --shadow: 0 1px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 6px 20px rgba(0,0,0,0.11);
}

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

html, body { min-height: 100%; }
body {
  font-family: 'Zen Kaku Gothic New', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--brand-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--brand-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; }
.small { font-size: 12px; color: var(--ink-3); }
.empty { color: #9ca3af; padding: 16px 0; }
.req { color: var(--danger); }
.loading { padding: 60px; text-align: center; color: var(--ink-3); }
.route-error { padding: 60px 20px; text-align: center; }
.route-error h2 { color: var(--danger); margin-bottom: 8px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: none; text-decoration: none;
  line-height: 1.3; transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(2,141,174,0.28); }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); text-decoration: none; }
.btn-primary:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; transform: none; }
.btn-secondary { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-secondary:hover { background: var(--brand-light); transform: translateY(-1px); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }
.btn-primary.small, .btn-secondary.small, .btn-danger.small { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ── Header ───────────────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: #fff; border-bottom: 1px solid #e8eef0;
  position: sticky; top: 0; z-index: 100;
}
/* hAIchi ロゴ: 全ページ共通で大型グラデ (ユーザートップと統一) */
.app-title {
  font-size: 26px; font-weight: 800; letter-spacing: -0.6px; line-height: 1;
  background: linear-gradient(120deg, #028DAE 0%, #05a8cc 45%, #016f8a 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: #028DAE;
}
.app-title:hover { filter: brightness(1.08); }

/* ヘッダー中央固定のカートピル (visitor top / account 共通) */
.visitor-app-header { position: relative; }
.cart-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #028DAE, #016f8a);
  color: #fff; padding: 8px 16px; border-radius: 22px; font-weight: 700;
  text-decoration: none; font-size: 14px;
  box-shadow: 0 3px 10px rgba(2,141,174,0.35);
}
.cart-pill:hover { background: #016f8a; }
.cart-pill .cart-cnt {
  background: #fff; color: #028DAE; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 700;
}
.cart-pill svg { width: 16px; height: 16px; flex: 0 0 auto; }
.cart-pill.hdr-cart-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
}
.cart-pill.hidden { display: none; }

/* ヘッダー右のアカウント丸アイコン (visitor top / account 共通) */
.hdr-account-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #028DAE, #016f8a);
  color: #fff; text-decoration: none;
  box-shadow: 0 2px 8px rgba(2,141,174,0.30);
}
.hdr-account-ico:hover { background: linear-gradient(135deg, #016f8a, #014f66); }
.hdr-account-ico svg { width: 18px; height: 18px; display: block; }
.hdr-left { display: flex; align-items: center; gap: 12px; }
.hdr-back { font-size: 13px; color: var(--ink-3); }
.hdr-title { font-size: 14px; color: var(--ink-2); }
.hdr-user { display: flex; align-items: center; gap: 10px; }
.hdr-role {
  font-size: 11px; font-weight: 700; background: var(--brand-light);
  color: var(--brand); padding: 3px 10px; border-radius: 20px;
}
.hdr-username { font-size: 13px; color: var(--ink-2); }
.hdr-link {
  background: #fff; border: 1px solid #e2e8eb; padding: 6px 12px; border-radius: 8px;
  font-size: 12px; cursor: pointer; color: var(--ink-2); font-family: inherit;
}
.hdr-link:hover { background: var(--brand-light); }

/* ── Card / Page ──────────────────────────────────────────────────────── */
.page { padding: 28px 20px; max-width: 1120px; margin: 0 auto; }
.page-section {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  margin-bottom: 18px; box-shadow: var(--shadow); border-left: 3px solid var(--brand);
}
.page-section h3 { font-size: 16px; margin-bottom: 14px; color: var(--ink); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.announce { background: var(--brand-light); border-left-color: var(--brand); }
.announce p { font-size: 13px; color: var(--brand-dark); margin: 0; }

/* ── Landing ──────────────────────────────────────────────────────────── */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.lp-main { flex: 1; max-width: 560px; margin: 0 auto; padding: 56px 20px 32px; width: 100%; }
.lp-brand { text-align: center; margin-bottom: 36px; }
.lp-logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; font-weight: 700;
  box-shadow: 0 6px 24px rgba(2,141,174,0.25);
}
.lp-title { font-size: 26px; font-weight: 700; color: #0f1e27; margin-bottom: 10px; text-align: center; }
.lp-lead { font-size: 14px; color: var(--ink-2); line-height: 1.8; text-align: center; }
.lp-primary-card {
  background: #fff; border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); border-left: 3px solid var(--brand); margin-top: 28px;
}
.lp-primary-card h3 { font-size: 16px; margin-bottom: 6px; }
.lp-primary-card p { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.lp-url-form { display: flex; gap: 8px; }
.lp-url-form input {
  flex: 1; padding: 11px 14px; border: 1.5px solid #d9eff4; border-radius: 10px;
  font-size: 14px; font-family: inherit;
}
.lp-url-form input:focus { outline: none; border-color: var(--brand); }
.lp-secondary {
  text-align: center; margin-top: 22px; font-size: 13px;
}
.lp-secondary a { font-weight: 600; }
.lp-footer {
  border-top: 1px solid #e8eef0; padding: 16px 20px; text-align: center;
  font-size: 12px; color: var(--ink-3); background: rgba(255,255,255,0.6);
}
.lp-footer a { color: var(--ink-3); margin: 0 8px; }
.lp-footer a:hover { color: var(--brand); }

/* ── Auth ─────────────────────────────────────────────────────────────── */
.auth-wrap { max-width: 460px; margin: 48px auto; padding: 0 18px; }
.auth-wrap.auth-wide { max-width: 620px; }
.auth-wrap h2 { font-size: 22px; margin-bottom: 8px; color: #0f1e27; }
.auth-sub { font-size: 13px; color: var(--ink-2); margin-bottom: 20px; }
.auth-form { background: #fff; padding: 26px; border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.auth-form input, .auth-form select, .auth-form textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid #d9eff4; border-radius: 10px;
  font-size: 14px; margin-top: 5px; font-family: inherit;
}
.auth-form input:focus, .auth-form select:focus, .auth-form textarea:focus {
  outline: none; border-color: var(--brand);
}
.auth-form .check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.auth-form .check-row input { width: auto; margin: 0; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0; }
.auth-aux { font-size: 12px; color: var(--ink-3); margin-top: 14px; text-align: center; line-height: 1.7; }
.auth-fieldset { border: 1px solid #e2eef1; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.auth-fieldset legend { font-size: 12px; font-weight: 700; color: var(--brand); padding: 0 6px; }
.auth-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* Password strength */
.pw-meter { margin-top: 8px; }
.pw-bar { height: 6px; background: #e8eef0; border-radius: 4px; overflow: hidden; }
.pw-bar-fill { height: 100%; width: 0; transition: width .25s ease, background .25s ease; }
.pw-label { font-size: 11px; margin-top: 4px; font-weight: 600; }
.pw-sug { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* Completion / verify page */
.notice-page { max-width: 480px; margin: 80px auto; text-align: center; padding: 0 20px; }
.notice-icon {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 20px;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 36px;
}
.notice-page h2 { font-size: 22px; margin-bottom: 12px; }
.notice-page p { color: var(--ink-2); font-size: 14px; line-height: 1.8; margin-bottom: 20px; }

/* ── Property grid ────────────────────────────────────────────────────── */
.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.prop-card {
  background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.prop-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.prop-thumb {
  height: 160px; background: #f0fafb; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid #e8eef0;
}
.prop-thumb img { max-width: 100%; max-height: 100%; }
.no-image { color: #9ca3af; font-size: 12px; }
.prop-body { padding: 14px; }
.prop-title { font-size: 14px; margin: 6px 0; font-weight: 700; }
.prop-meta { font-size: 12px; color: var(--ink-3); margin: 2px 0; }
.prop-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── Badge ────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-verified  { background: #d1fae5; color: #065f46; }
.badge-published { background: var(--brand-light); color: var(--brand-dark); }

/* ── Image preview ────────────────────────────────────────────────────── */
.img-preview { background: #f0fafb; padding: 10px; border-radius: 10px; text-align: center; margin-top: 8px; }
.img-preview img { max-width: 100%; max-height: 320px; border-radius: 6px; }

/* ── Workflow tabs ────────────────────────────────────────────────────── */
.wf-tabs { display: flex; gap: 6px; background: #fff; border-radius: 12px; padding: 6px; margin-bottom: 18px; box-shadow: var(--shadow); }
.wf-tab {
  flex: 1; padding: 10px; background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--ink-3); border-radius: 8px; font-family: inherit; font-weight: 600;
}
.wf-tab:hover { background: var(--brand-light); }
.wf-tab.active { background: var(--brand); color: #fff; }
.wf-body { background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }
.step-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 16px; }
.step-image img { max-width: 100%; max-height: 420px; display: block; margin: 0 auto; border-radius: 8px; }
.step-controls { padding: 16px; background: #f0fafb; border-radius: 12px; }
.ctl-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.status { font-size: 12px; color: var(--ink-2); min-height: 18px; padding: 6px 0; }

.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.style-card { background: #f0fafb; padding: 10px; border-radius: 12px; text-align: center; border: 2px solid transparent; transition: border .15s; }
.style-card.confirmed { border-color: var(--ok); }
.style-card h4 { font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.style-card img { max-width: 100%; max-height: 200px; border-radius: 6px; }
.style-card .empty { display: inline-block; padding: 50px 0; }
.style-card-actions { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }

.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.layout-card { background: #f0fafb; padding: 14px; border-radius: 12px; box-shadow: var(--shadow); }
.layout-card h4 { font-size: 14px; margin-bottom: 6px; }
.layout-card .lc-thumb { background:#fff; border-radius:8px; height:140px; display:flex;align-items:center;justify-content:center; overflow:hidden; margin:8px 0;}
.layout-card .lc-thumb img { max-width:100%; max-height:100%; }
.layout-actions { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px;}

.check-list { list-style: none; margin: 14px 0; }
.check-list li { padding: 7px 0; font-size: 14px; }

/* ── Polygon editor ───────────────────────────────────────────────────── */
.poly-stage { position: relative; background: #f0fafb; margin: 14px 0; overflow: visible; min-height: 360px; display:flex; align-items:center; justify-content:center; }
.poly-stage img { max-width: 100%; max-height: 60vh; display: block; }
.polygon-editor-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.polygon-editor-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  background: #fff; border-radius: 10px; margin-top: 10px; box-shadow: var(--shadow);
}
.polygon-editor-title { flex: 1; font-size: 12px; color: var(--ink-2); }
/* 部屋名は画像下のリストで編集 (画像上には番号バッジのみ) */
.poly-room-badge {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; border: 2px solid #fff;
  pointer-events: none; box-shadow: 0 1px 4px rgba(0,0,0,0.3); z-index: 45;
}
.poly-room-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.poly-room-row {
  display: flex; align-items: center; gap: 10px; background: #f0fafb;
  padding: 10px 14px; border-radius: 10px;
}
.poly-room-row .prr-num {
  width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.poly-room-row input.prr-name { flex: 1; padding: 6px 10px; border: 1px solid #d9eff4; border-radius: 8px; font-size: 13px; font-family: inherit; }
.poly-room-row select.prr-type { padding: 6px 8px; border: 1px solid #d9eff4; border-radius: 8px; font-size: 12px; font-family: inherit; }
.poly-room-row button { padding: 5px 10px; font-size: 11px; }

/* ── Publish box ──────────────────────────────────────────────────────── */
.publish-box { background: #f0fafb; padding: 18px; border-radius: 12px; margin-bottom: 14px; }
.url-row { display: flex; gap: 8px; margin: 10px 0; }
.url-row input { flex: 1; padding: 8px 12px; border: 1px solid #d9eff4; border-radius: 8px; font-family: monospace; font-size: 12px; }
.prop-detail-head { display: flex; align-items: center; justify-content: space-between; }

/* ── Visitor view ─────────────────────────────────────────────────────── */
.visitor-main { padding: 14px; max-width: 1000px; margin: 0 auto; }
.visitor-meta { font-size: 13px; color: var(--ink-2); padding: 4px 0 10px; }
.layout-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
.layout-tab {
  padding: 8px 16px; background: #fff; border: 1.5px solid #d9eff4; border-radius: 20px;
  cursor: pointer; font-size: 12px; white-space: nowrap; font-family: inherit; font-weight: 600; color: var(--ink-2);
}
.layout-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.visitor-toolbar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:8px 0; }
.visitor-toolbar label { font-size:12px; color:var(--ink-2); display:flex; align-items:center; gap:6px; }
.visitor-toolbar select { padding:6px 10px; border:1.5px solid #d9eff4; border-radius:8px; font-family:inherit; font-size:12px; }
.visitor-canvas-area {
  position: relative; background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  min-height: 320px; max-height: 62vh;
}
.floorplan { max-width: 100%; max-height: 62vh; display: block; }
.placed-layer { position: absolute; inset: 0; pointer-events: none; }
.placed-item { position: absolute; pointer-events: auto; transform: translate(-50%, -50%); touch-action: none; cursor: grab; user-select: none; }
.placed-item-rotor { width: 100%; height: 100%; transform-origin: center center; }
.placed-item-rotor svg { width: 100%; height: 100%; display: block; }
.placed-item.selected .placed-item-rotor svg { outline: 2px solid var(--brand); outline-offset: 2px; }
.delete-btn {
  position: absolute; top: -10px; right: -10px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--danger); color: #fff; border: 2px solid #fff;
  cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 12px; z-index: 2;
}
.placed-item.selected .delete-btn { display: flex; }
.visitor-actions { padding: 10px 0; }
.palette { display: flex; gap: 8px; padding: 12px 0; overflow-x: auto; }
.palette-item {
  flex: 0 0 auto; width: 82px; background: #fff; border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px;
}
.variant-select { width: 100%; font-size: 10px; padding: 2px; font-family: inherit; }
.palette-icon { width: 48px; height: 48px; cursor: grab; touch-action: none; }
.drag-ghost { position: fixed; pointer-events: none; z-index: 9999; transform: translate(-50%, -50%); opacity: 0.85; }

/* ── UI System (modal / toast / progress) ────────────────────────────── */
.ui-backdrop {
  position: fixed; inset: 0; background: rgba(15,30,39,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
  opacity: 0; transition: opacity .18s ease; padding: 20px;
}
.ui-backdrop.show { opacity: 1; }
.ui-modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25); overflow: hidden;
  transform: scale(0.94); opacity: 0; transition: transform .18s ease, opacity .18s ease;
}
.ui-modal.show { transform: scale(1); opacity: 1; }
.ui-modal-head { padding: 18px 22px 0; font-size: 16px; font-weight: 700; color: #0f1e27; }
.ui-modal-body { padding: 14px 22px 18px; }
.ui-msg { font-size: 14px; color: var(--ink-2); line-height: 1.7; white-space: pre-wrap; }
.ui-input { width: 100%; padding: 10px 12px; border: 1.5px solid #d9eff4; border-radius: 10px; font-size: 14px; margin-top: 12px; font-family: inherit; }
.ui-input:focus { outline: none; border-color: var(--brand); }
.ui-modal-foot { padding: 0 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.ui-toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ui-toast {
  background: #0f1e27; color: #fff; padding: 11px 20px; border-radius: 24px;
  font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  opacity: 0; transform: translateY(-12px); transition: all .25s ease; max-width: 90vw;
}
.ui-toast.show { opacity: 1; transform: translateY(0); }
.ui-toast-success { background: var(--ok); }
.ui-toast-error { background: var(--danger); }
.ui-toast-info { background: var(--brand); }
.ui-prog { padding: 6px 0; }
.ui-prog-bar { height: 8px; background: #e8eef0; border-radius: 4px; overflow: hidden; }
.ui-prog-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); width: 0; transition: width .4s ease; }
.ui-prog-label { font-size: 13px; color: var(--ink-2); margin-top: 12px; text-align: center; }
.ui-prog-steps { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.ui-prog-step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-3); }
.ui-prog-dot { width: 10px; height: 10px; border-radius: 50%; background: #d9eff4; flex-shrink: 0; }
.ui-prog-active { color: var(--brand); font-weight: 600; }
.ui-prog-active .ui-prog-dot { background: var(--brand); animation: pulse 1.2s infinite; }
.ui-prog-done { color: var(--ok); }
.ui-prog-done .ui-prog-dot { background: var(--ok); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Preference panel (reuse) ─────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(15,30,39,0.45); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-content { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e8eef0; }
.modal-header h2 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--ink-3); }
.modal-body { padding: 18px 20px; }
.modal-footer { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #e8eef0; }
.modal-instructions { font-size: 13px; color: var(--ink-2); background: var(--brand-light); padding: 10px 14px; border-left: 3px solid var(--brand); border-radius: 8px; margin-bottom: 14px; }
.pref-group { margin-bottom: 14px; }
.pref-group h3 { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; }
.pref-options { display: flex; flex-wrap: wrap; gap: 7px; }
.pref-pill { font-size: 12px; padding: 7px 14px; background: #f0fafb; color: var(--ink-2); border: 1.5px solid #d9eff4; border-radius: 20px; cursor: pointer; font-family: inherit; }
.pref-pill.selected { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── OCR 診断 (案A) + 半間グリッド (案B) ──────────────────────────────── */
.ocr-stage { position: relative; display: inline-block; max-width: 100%; }
.ocr-stage img { max-width: 100%; max-height: 420px; display: block; }
.ocr-overlay { position: absolute; inset: 0; pointer-events: none; }
.ocr-grid { position: absolute; left: 0; top: 0; pointer-events: none; }
.ocr-badge {
  position: absolute; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%; color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.diag-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.diag-table th, .diag-table td { padding: 6px 8px; border-bottom: 1px solid #e8eef0; text-align: left; }
.diag-table th { color: var(--ink-3); font-weight: 600; }
.diag-table tr.diag-off { opacity: 0.45; }
.diag-num {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: #fff; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}

/* ── コスト概算チップ ─────────────────────────────────────────────────── */
.cost-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 4px 10px; border-radius: 12px;
  background: var(--brand-light); color: var(--brand-dark);
  font-weight: 600; white-space: nowrap;
}
.cost-pill::before { content: '💰'; font-size: 11px; }

/* ── 家具管理 (admin) ─────────────────────────────────────────────────── */
.furni-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 14px; margin-top: 12px; }
.furni-card { background:#fff; border:1px solid #e8eef0; border-radius:12px; padding:12px; text-align:center; box-shadow:var(--shadow); }
.furni-thumb { height:96px; display:flex; align-items:center; justify-content:center; background:#f0fafb; border-radius:8px; overflow:hidden; }
.furni-thumb.lg { height:200px; }
.furni-thumb svg, .furni-thumb img { max-width:100%; max-height:100%; }
.furni-name { font-weight:700; font-size:13px; margin:8px 0 2px; }
.furni-src { margin:6px 0; }
.furni-actions { display:flex; gap:6px; justify-content:center; flex-wrap:wrap; }
.furni-edit { flex:1; display:grid; grid-template-columns: 280px 1fr; gap:20px; padding:18px; overflow:auto; }
.furni-edit-preview { display:flex; flex-direction:column; gap:10px; align-items:center; }
.furni-edit-form label { display:block; margin-bottom:10px; font-weight:600; }
.furni-edit-form .ui-input { margin-top:4px; }
.var-row { display:flex; align-items:center; gap:6px; margin-bottom:6px; }
.var-row .ui-input { margin-top:0; }

/* 画像マトリクス (バリアント × スタイル) */
.furni-edit-v2 { flex:1; overflow:auto; padding: 18px; }
.furni-edit-v2 .form-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap:14px; }
.image-matrix-wrap { overflow-x: auto; }
.img-matrix { display: grid; gap: 6px; min-width: 760px; }
.img-matrix .im-header { background: var(--brand-light); color: var(--brand-dark); padding: 8px; font-weight: 700; font-size: 12px; text-align: center; border-radius: 6px; }
.img-matrix .im-corner { background: #f4f9fa; color: var(--ink-2); }
.img-matrix .im-rowlabel { background: #f4f9fa; padding: 8px; font-size: 11px; line-height: 1.35; border-radius: 6px; }
.img-matrix .im-cell { background: #f9fbfc; border: 1px solid #e8eef0; border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.img-matrix .im-thumb { background: #fff; border-radius: 6px; height: 90px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.img-matrix .im-thumb img { max-width: 100%; max-height: 100%; }
.img-matrix .im-actions { display: flex; gap: 2px; justify-content: center; }
.img-matrix .im-actions .btn-ghost { padding: 2px 6px; font-size: 14px; line-height: 1; }
.img-matrix .im-actions label { display: inline-flex; align-items: center; }

@media (max-width:768px){ .furni-edit{ grid-template-columns:1fr; } }

/* ── PlacementEditor overlay ──────────────────────────────────────────── */
.pe-overlay {
  position: fixed; inset: 0; z-index: 2500; background: var(--bg);
  background-image: linear-gradient(var(--brand-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--brand-line) 1px, transparent 1px);
  background-size: 28px 28px; display: flex; flex-direction: column;
}
.pe-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: #fff; border-bottom: 1px solid #e8eef0;
}
.pe-title { font-weight: 700; color: var(--ink); }
.pe-head-actions { display: flex; gap: 8px; }
.pe-canvas-area {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin: 12px; background: #fff; border-radius: 12px; box-shadow: var(--shadow);
}
.pe-floorplan { max-width: 100%; max-height: 100%; display: block; }
.pe-placed { position: absolute; inset: 0; pointer-events: none; }
.pe-placed .placed-item { pointer-events: auto; }
.pe-palette {
  display: flex; gap: 8px; padding: 12px 18px; overflow-x: auto;
  background: #fff; border-top: 1px solid #e8eef0;
}
.rotate-btn {
  position: absolute; top: -10px; left: -10px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--brand); color: #fff; border: 2px solid #fff;
  cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 12px; z-index: 2;
}
.placed-item.selected .rotate-btn { display: flex; }

/* ── Furniture icon themes (visitor selectable) ──────────────────────── */
.icon-theme-simple .placed-item-rotor svg,
.icon-theme-simple .palette-icon svg { filter: grayscale(1) contrast(1.1); }
.icon-theme-mono .placed-item-rotor svg,
.icon-theme-mono .palette-icon svg { filter: grayscale(1) brightness(0.4); }
.icon-theme-nordic .placed-item-rotor svg,
.icon-theme-nordic .palette-icon svg { filter: saturate(0.6) brightness(1.08); }

@media (max-width: 768px) {
  .step-row { grid-template-columns: 1fr; }
  .wf-tab { font-size: 11px; padding: 8px 4px; }
  .lp-url-form { flex-direction: column; }
}

/* ── Visitor view: mobile responsive (2026-07 追加) ──────────────────── */
/*   お客様向け /view/:id 画面をスマホでも見やすく:
 *     - ヘッダをコンパクト化 (username 非表示)
 *     - 余白詰めて図面と家具パレットに縦スペースを譲る
 *     - 家具パレットのタッチターゲットを維持しつつ 1 行に多く並ぶよう
 *     - 横向きなら図面をより大きく表示 (max-height 拡張)
 *   .visitor-main を root にした高特異性で inline style 上書きを回避。
 */
@media (max-width: 720px) {
  /* ヘッダ */
  .app-header { padding: 10px 12px; }
  .app-title { font-size: 23px; }
  .visitor-main .app-header .hdr-title { font-size: 12px; font-weight: 600; }
  .visitor-main .app-header .hdr-username { display: none; }
  .hdr-role { font-size: 10px; padding: 2px 8px; }
  .hdr-user { gap: 6px; }

  /* メイン領域 */
  .visitor-main { padding: 8px; font-size: 14px; }
  .visitor-main .visitor-meta { font-size: 13px; padding: 2px 0 6px; line-height: 1.4; }
  .visitor-main .visitor-meta p { margin: 0; }

  /* レイアウトタブ */
  .visitor-main .layout-tabs { gap: 4px; padding-bottom: 6px; }
  .visitor-main .layout-tab { padding: 6px 12px; font-size: 12px; }

  /* テイスト・アイコンテーマ セレクタ */
  .visitor-main .visitor-toolbar { gap: 6px; padding: 6px 0; }
  .visitor-main .visitor-toolbar label { font-size: 12px; gap: 4px; }
  .visitor-main .visitor-toolbar select { padding: 5px 8px; font-size: 12px; }

  /* キャンバス */
  .visitor-canvas-area { min-height: 240px; max-height: 55vh; border-radius: 8px; }
  .floorplan { max-height: 55vh; }

  /* 家具パレット (下部) */
  .palette { padding: 8px 0 12px; gap: 6px; }
  .palette-item { width: 68px; padding: 6px 3px; font-size: 10px; }
  .visitor-main .palette-item span { font-size: 11px; }
  .variant-select { font-size: 10px; padding: 2px 4px; }
  .palette-icon { width: 42px; height: 42px; }
}

@media (max-width: 480px) {
  .app-header { padding: 8px 10px; }
  .app-title { font-size: 23px; }
  .visitor-main .app-header .hdr-title { font-size: 11px; }
  .hdr-role { font-size: 9px; padding: 2px 6px; }
  /* 極小画面ではロールバッジも非表示にする */
  .visitor-main .app-header .hdr-role { display: none; }

  .visitor-main { padding: 6px; }
  .visitor-main .layout-tab { padding: 5px 10px; font-size: 11px; }
  .visitor-main .visitor-toolbar select { padding: 4px 6px; font-size: 11px; }

  .visitor-canvas-area { min-height: 200px; max-height: 52vh; }
  .floorplan { max-height: 52vh; }

  .palette-item { width: 62px; padding: 5px 2px; }
  .palette-icon { width: 38px; height: 38px; }
}

/* スマホ横向き: 上下スペース節約して図面を拡大 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .visitor-canvas-area { max-height: 72vh; }
  .floorplan { max-height: 72vh; }
  .visitor-main { padding: 4px 8px; }
  .layout-tabs { padding-bottom: 4px; }
  .visitor-toolbar { padding: 4px 0; }
}
