:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #23231f;
  --muted: #6d6b63;
  --line: #e2dfd6;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --danger: #b3412f;
  --radius: 10px;
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* ロボット対策の確認枠（疑われたときだけ中身が出る） */
.captcha-host { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1000; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
  text-decoration: none; color: var(--ink); font-size: 14px;
}
.btn:hover { border-color: #c9c5b8; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .4; cursor: default; }

/* 広告枠（AdSense申請が通ったら中身を差し替え、body に ads-on を付けて表示する） */
body:not(.ads-on) .ad-slot { display: none !important; }
.ad-slot {
  border: 1px dashed #cfcabd; border-radius: var(--radius);
  color: #a19d91; font-size: 12px; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #faf9f6, #faf9f6 8px, #f3f1ec 8px, #f3f1ec 16px);
  min-height: 90px;
}

/* ---------- トップ ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; font-size: 18px; letter-spacing: .02em; color: var(--ink); text-decoration: none; }
.logo span { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hero { padding: 48px 0 32px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; }
.hero h1 { font-size: 34px; line-height: 1.35; margin: 0 0 14px; }
.hero p { color: var(--muted); line-height: 1.8; margin: 0 0 22px; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .terms-note { flex-basis: 100%; margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.hero-figure { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.hero-figure canvas { width: 100%; height: auto; display: block; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 32px; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.feature h3 { margin: 0 0 6px; font-size: 15px; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 12px; }
.section-title h2 { font-size: 20px; margin: 0; }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.plan-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.plan-card canvas { width: 100%; aspect-ratio: 4/3; display: block; background: #fff; border-bottom: 1px solid var(--line); cursor: pointer; }
.plan-card .meta { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.plan-card .name { font-weight: 600; font-size: 14px; }
.plan-card .date { color: var(--muted); font-size: 12px; }
.plan-card .actions { display: flex; gap: 6px; padding: 0 12px 12px; }
.plan-card .actions .btn { padding: 4px 8px; font-size: 12px; }
.empty { color: var(--muted); padding: 28px; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.site-footer { margin-top: 48px; padding: 24px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.site-footer .copy { margin-top: 6px; }

/* ---------- 規約・使い方などの読み物 ---------- */
.doc { max-width: 760px; padding-top: 28px; padding-bottom: 8px; line-height: 1.85; font-size: 15px; }
.doc h1 { font-size: 26px; margin: 0 0 6px; }
.doc h2 { font-size: 17px; margin: 30px 0 8px; padding-top: 4px; border-top: 1px solid var(--line); }
.doc .card h2 { border: 0; margin: 0 0 6px; padding: 0; font-size: 15px; }
.doc ol, .doc ul { padding-left: 1.5em; }
.doc li { margin: 4px 0; }
.doc-date, .doc .muted { color: var(--muted); font-size: 13px; }
.doc-sign { margin-top: 32px; color: var(--muted); font-size: 14px; }
.doc-table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; background: var(--panel); }
.doc-table th { background: #f0eee8; }
.doc .faq dt { font-weight: 700; margin-top: 18px; }
.doc .faq dd { margin: 4px 0 0; color: #3d3c37; }
.doc .steps li { margin: 8px 0; }
.contact-mail { font-size: 20px; font-weight: 700; }
.doc .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.doc .danger-zone { border-color: #e6c3bb; }
.doc .notice { background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; }
.doc .mono { font-family: ui-monospace, Menlo, monospace; margin: 0; overflow-wrap: anywhere; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.stack-form { display: grid; gap: 8px; max-width: 360px; }
.stack-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.stack-form .btn { justify-self: start; }
.row-form input { flex: 1; min-width: 200px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 760px) { .doc-table { font-size: 12px; } .doc-table th, .doc-table td { padding: 5px 6px; } }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 28px; }
  .hero h1 { font-size: 26px; }
  .features { grid-template-columns: 1fr; }
}

/* ---------- エディタ ---------- */
.editor { user-select: none; -webkit-user-select: none; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto;
}
.topbar .plan-name { border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; font-weight: 600; min-width: 140px; background: transparent; }
.topbar .plan-name:hover, .topbar .plan-name:focus { border-color: var(--line); outline: none; background: #fff; }
.topbar .spacer { flex: 1; }
.floors { display: flex; gap: 4px; }
.floors .btn { padding: 5px 10px; }
.floors .btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.main { display: grid; grid-template-columns: 64px 1fr 260px; min-height: 0; }
.tools { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; overflow-y: auto; }
.tool {
  border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; font-size: 11px; color: var(--muted);
}
.tool svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tool:hover { background: #f4f2ed; }
.tool.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.stage { position: relative; min-width: 0; min-height: 0; background: #fbfaf7; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.hint {
  position: absolute; left: 12px; bottom: 12px; background: rgba(35,35,31,.78); color: #fff;
  font-size: 12px; padding: 6px 10px; border-radius: 6px; pointer-events: none; max-width: calc(100% - 190px);
}
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; }
.zoom .btn { padding: 4px 10px; }

.side { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side .scroll { flex: 1; overflow-y: auto; padding: 12px; }
.side h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.side .group { margin-bottom: 18px; }
.presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.preset { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px 8px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 6px; text-align: left; }
.preset i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); flex: none; }
.preset.active { border-color: var(--accent); background: var(--accent-soft); }
.field { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; background: #fff; }
.row { display: flex; gap: 6px; flex-wrap: wrap; }
.stat { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.stat b { font-variant-numeric: tabular-nums; }
.side .ad-slot { margin: 12px; min-height: 250px; }
.statusbar { background: var(--panel); border-top: 1px solid var(--line); padding: 5px 12px; font-size: 12px; color: var(--muted); display: flex; gap: 16px; }

@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .tools { flex-direction: row; border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 4px 8px; }
  .tool { min-width: 52px; }
  .side { border-left: none; border-top: 1px solid var(--line); max-height: 34vh; }
  .side .ad-slot { min-height: 60px; }
  .hint { display: none; }
}

@media print {
  .topbar, .tools, .side, .statusbar, .zoom, .hint { display: none !important; }
  .main { grid-template-columns: 1fr; }
}
.editor input { user-select: text; -webkit-user-select: text; }

/* ---------- 有料機能の印 ---------- */
.pro {
  display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 4px;
  background: #b8862b; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; vertical-align: middle;
}

/* ---------- ツールの横に出る選択肢 ---------- */
.main { position: relative; }
.tool.has-menu { position: relative; }
.tool.has-menu::after {
  content: ""; position: absolute; right: 4px; bottom: 4px;
  border: 4px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .5;
}
.flyout {
  position: absolute; z-index: 20; width: 272px; max-height: calc(100% - 12px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  box-shadow: 0 10px 28px rgba(35, 35, 31, .16);
}
.flyout[hidden] { display: none; }
.flyout-title { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.flyout-title:not(:first-child) { margin-top: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 6px; font-size: 12px; cursor: pointer;
}
.seg button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- 下の設定バー ---------- */
.statusbar { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.settings { display: flex; gap: 14px; flex-wrap: wrap; }
.settings label { display: flex; align-items: center; gap: 6px; }
.settings select { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: #fff; font-size: 12px; }
.status { display: flex; gap: 16px; }
.status-msg { color: var(--accent); font-weight: 600; }

/* ---------- 会員 ---------- */
.auth-host { display: flex; gap: 6px; align-items: center; }
.user-chip { font-size: 13px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(35, 35, 31, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; width: 100%; max-width: 400px; background: var(--panel); border-radius: 14px; padding: 26px 24px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25); user-select: text; -webkit-user-select: text;
}
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal-close { position: absolute; right: 12px; top: 10px; border: none; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.modal-reason { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0 0 12px; }
.form-row { display: flex; flex-direction: column; gap: 5px; font-size: 13px; margin-bottom: 12px; }
.form-row input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 15px; }
.form-row input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.agree { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.6; }
.agree[hidden] { display: none; }
.form-error { color: var(--danger); font-size: 12px; min-height: 18px; margin: 4px 0 8px; }
.form-error.info { color: var(--accent); }
.btn.block { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.modal-switch { text-align: center; font-size: 13px; margin: 14px 0 0; }
.modal-note { text-align: center; font-size: 11px; color: #a19d91; margin: 8px 0 0; }

/* トップの会員向け案内 */
.signup-card {
  grid-column: 1 / -1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.signup-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.header-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 860px) {
  .flyout { width: min(272px, calc(100% - 12px)); }
  .statusbar { font-size: 11px; }
}

/* 建具・サッシの種類（1列で幅も見せる） */
.presets.one { grid-template-columns: 1fr; }
.presets.one .preset { justify-content: space-between; }
.preset small { color: #a19d91; font-size: 11px; }
/* 重なり順 */
.order { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.order .row { margin-top: 4px; }
.order .btn { padding: 4px 8px; font-size: 12px; }

/* ---------- メニューバー ---------- */
.menubar { display: flex; gap: 2px; }
.menu { position: relative; }
.menu-btn { border: 1px solid transparent; background: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.menu-btn:hover, .menu-btn.open { background: #f1efe9; border-color: var(--line); }
.menu-list {
  position: fixed; z-index: 50; min-width: 230px; margin-top: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(35,35,31,.16);
}
.menu-list[hidden] { display: none; }
.menu-list button {
  display: flex; justify-content: space-between; gap: 16px; width: 100%; border: none; background: none; text-align: left;
  padding: 7px 10px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.menu-list button:hover { background: var(--accent-soft); }
.menu-list kbd { font-family: inherit; color: #8a877e; font-size: 12px; }
.menu-list hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- ツールの横のメニュー（追加分） ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.flyout { max-height: calc(100% - 12px); }
.flyout-note { font-size: 11px; color: #8a877e; margin: 8px 0 0; line-height: 1.6; }
.preset span { flex: 1; }
.preset:disabled { opacity: .4; cursor: default; }
.field.slim { grid-template-columns: 70px 1fr; margin-top: 10px; }

/* ---------- 右パネル（追加分） ---------- */
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 6px 0; }
.note { font-size: 11px; color: #8a877e; line-height: 1.6; margin: 8px 0 0; }
.btn-row { margin-top: 8px; }
.btn-row .btn, .align-grid .btn { padding: 5px 9px; font-size: 12px; }
.align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 4px; }
.modal textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; font-size: 14px; }
.modal .row { display: flex; gap: 8px; }

/* 図面の右下の面積表示 */
.area-box {
  position: absolute; right: 12px; bottom: 52px; background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.6; color: var(--ink); pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.btn.block-sm { width: 100%; justify-content: center; margin: 8px 0 4px; font-size: 12px; padding: 6px 8px; background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (max-width: 860px) { .area-box { display: none; } }

/* 下絵のレイヤー */
.ul-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ul-row { display: flex; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.ul-row.active { border-color: var(--accent); background: var(--accent-soft); }
.ul-thumb { width: 54px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #f6f5f1; cursor: pointer; flex: none; overflow: hidden; }
.ul-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ul-body { flex: 1; min-width: 0; }
.ul-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.ul-head .check { margin: 0; font-size: 12px; }
.ul-btns { display: flex; gap: 2px; }
.ul-btns .btn { padding: 2px 6px; font-size: 11px; }
.ul-alpha { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.ul-alpha input { flex: 1; min-width: 0; }
.ul-alpha span { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.flyout { width: 300px; }
/* 部品の絵つきの選択肢 */
.presets.icons { grid-template-columns: repeat(3, 1fr); }
.preset.icon { flex-direction: column; align-items: center; gap: 2px; padding: 4px; text-align: center; }
.preset.icon img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: contain; background: #fff; border-radius: 4px; }
.preset.icon span { font-size: 10.5px; line-height: 1.3; }
.preset.icon small { font-size: 10px; }
details.edges { margin: 6px 0; font-size: 12px; }
details.edges summary { cursor: pointer; color: var(--muted); margin-bottom: 6px; }
details.edges small { color: #a19d91; margin-left: 4px; }
