:root {
  --brand: #1d4ed8;
  --brand-dark: #173aa8;
  --accent: #f59e0b;
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #dde3ea;
  --text: #1f2937;
  --muted: #6b7280;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- header ---------- */
#header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 16px; height: 56px; flex: 0 0 auto; gap: 12px;
}
.hd-brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
#hd-site-link { text-decoration: none; color: var(--brand); font-weight: 900; font-size: 18px; white-space: nowrap; }
.hd-app-name { font-size: 13px; color: var(--muted); white-space: nowrap; }
.beta { font-size: 10px; color: var(--accent); margin-left: 2px; font-weight: 700; }
.hd-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; text-decoration: none; display: inline-block; line-height: 1.4;
}
.btn:hover { background: #f3f6fa; }
.btn.ghost { background: transparent; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700;
}
.btn.primary:hover { background: var(--brand-dark); }
.btn.large { padding: 12px 32px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- layout ---------- */
#main { display: flex; flex: 1 1 auto; min-height: 0; }
#sidebar {
  width: 220px; flex: 0 0 auto; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; padding: 12px;
}
#props {
  width: 250px; flex: 0 0 auto; background: var(--panel);
  border-left: 1px solid var(--line); overflow-y: auto; padding: 12px;
}
.sb-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.sb-note { font-size: 11px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.props-empty { font-size: 12px; color: var(--muted); line-height: 1.7; }

/* templates */
#template-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-item { cursor: pointer; border: 2px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.tpl-item:hover { border-color: var(--brand); }
.tpl-item img { width: 100%; display: block; border-radius: 4px; background: #fff; }
.tpl-item .tpl-name { font-size: 11px; margin-top: 4px; color: var(--text); text-align: center; }

/* ---------- center ---------- */
#center { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
#toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 12px;
}
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-group + .tb-group { border-left: 1px solid var(--line); padding-left: 14px; }
.tb-btn {
  border: 1px solid transparent; background: transparent; border-radius: 6px;
  padding: 6px 8px; font-size: 12px; cursor: pointer; font-family: inherit; color: var(--text);
  display: inline-flex; align-items: center; gap: 4px;
}
.tb-btn:hover { background: #eef2f7; }
.tb-ic {
  font-weight: 900; font-family: Georgia, serif; font-size: 14px;
}
.tb-label { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
input[type="color"] { width: 28px; height: 24px; border: 1px solid var(--line); border-radius: 4px; padding: 1px; background: #fff; cursor: pointer; }

#canvas-wrap { flex: 1 1 auto; overflow: auto; display: flex; }
#stage-holder { margin: auto; padding: 32px; }
#stage-container { box-shadow: 0 4px 24px rgba(0,0,0,.14); background: #fff; }

#page-tabs {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border-top: 1px solid var(--line); padding: 8px 16px;
}
.page-tab {
  border: 1px solid var(--line); background: #fff; border-radius: 20px;
  padding: 6px 20px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.page-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
#size-note { margin-left: auto; font-size: 11px; color: var(--muted); }

/* ---------- props panel ---------- */
.pp-section { margin-bottom: 14px; }
.pp-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: block; }
.pp-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
#props textarea, #props input[type="text"], #props input[type="number"], #props select {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
  font-size: 13px; font-family: inherit;
}
#props textarea { resize: vertical; }
.pp-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 5px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.pp-btn:hover { background: #f3f6fa; }
.pp-btn.danger { color: #b91c1c; border-color: #f3c6c6; }
.pp-btn.danger:hover { background: #fdf1f1; }
.pp-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pp-num { width: 64px !important; }

/* ---------- modal ---------- */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#quote-modal {
  background: #fff; border-radius: 12px; width: 640px; max-width: 100%;
  max-height: 92vh; overflow-y: auto; padding: 28px 32px; position: relative;
}
#modal-close {
  position: absolute; top: 10px; right: 14px; border: 0; background: none;
  font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1;
}
#quote-modal h2 { margin: 0 0 10px; font-size: 20px; }
.modal-lead { font-size: 13px; color: var(--text); line-height: 1.8; margin: 0 0 16px; }
#quote-preview { display: flex; gap: 10px; margin-bottom: 18px; }
#quote-preview .qp-item { flex: 1; text-align: center; }
#quote-preview img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#quote-preview .qp-cap { font-size: 11px; color: var(--muted); margin-top: 4px; }

.qf-row { margin-bottom: 12px; }
.qf-row > label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.req {
  background: #dc2626; color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px;
}
.qf-row input[type="text"], .qf-row input[type="email"], .qf-row input[type="tel"],
.qf-row select, .qf-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 10px; font-size: 14px; font-family: inherit;
}
.qf-consent { margin-top: 16px; }
.consent-label { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 400 !important; cursor: pointer; }
.consent-label input { margin-top: 3px; }
.qf-submit-row { text-align: center; margin-top: 20px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.sending-box { text-align: center; padding: 40px 0; }
.spinner {
  width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; margin: 0 auto 16px; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- misc ---------- */
.hidden { display: none !important; }
.hidden-input { display: none; }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; font-size: 13px; padding: 10px 20px;
  border-radius: 8px; z-index: 99; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

/* text edit overlay */
.text-edit-overlay {
  position: absolute; border: 1px dashed var(--brand); background: rgba(255,255,255,.95);
  outline: none; resize: none; overflow: hidden; z-index: 40; font-family: inherit;
}

@media (max-width: 1100px) {
  #props { width: 210px; }
  #sidebar { width: 180px; }
}
@media (max-width: 860px) {
  #main { flex-direction: column; overflow-y: auto; }
  #sidebar, #props { width: 100%; border: 0; border-bottom: 1px solid var(--line); }
  #template-list { flex-direction: row; overflow-x: auto; }
  .tpl-item { flex: 0 0 130px; }
  #app { height: auto; }
}
