/* ブラウザエディター（/editor/）専用。2026-12-05 UI/UX 見直し
   PC：左＝タブ（デザイン・文字・写真・AI文章）／中央＝はがき／右＝選んだものの編集＋保存
   スマホ：はがき → 選んだものの編集 → タブ → 保存 の順に縦に並べる */

.ed-head { padding-top: 4px; }
.ed-title { font-size: 1.35rem; margin: .3em 0 .2em; }
.ed-lead { margin: 0 0 12px; color: var(--muted); font-size: .92rem; }

.ed-app {
  --ed-bg: #eef3f8;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 290px;
  grid-template-areas: "panel stage side";
  gap: 16px;
  align-items: start;
  max-width: 1320px;
  margin: 0 auto 32px;
  padding: 16px;
  background: var(--ed-bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.ed-panel { grid-area: panel; }
.ed-stage { grid-area: stage; }
.ed-side { grid-area: side; }
.ed-panel, .ed-inspector, .ed-save {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(31,58,95,.06);
}
/* PC ではタブとその中身・右の列を画面の中に収め、ページ全体をスクロールしなくても使えるようにする（ヘッダー 64px 分を引く） */
@media (min-width: 1000px) {
  .ed-panel, .ed-side { position: sticky; top: 76px; }
  .ed-panel { display: flex; flex-direction: column; max-height: calc(100vh - 92px); }
  .ed-pane { overflow-y: auto; }
  .ed-side { max-height: calc(100vh - 92px); overflow-y: auto; }
}

/* タブ */
.ed-tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); flex: none; }
.ed-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 2px 8px; border: 0; border-bottom: 3px solid transparent; background: none;
  font: inherit; font-size: .82rem; font-weight: 700; color: var(--muted); cursor: pointer;
}
.ed-tab:hover { color: var(--ai); background: var(--ai-soft); }
.ed-tab[aria-selected="true"] { color: var(--ai); border-bottom-color: var(--ai); }
.ed-tab-num {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--line); color: #fff; font-size: .72rem;
}
.ed-tab[aria-selected="true"] .ed-tab-num { background: var(--ai); }
.ed-pane { padding: 12px; }
.ed-pane[hidden] { display: none; }
.ed-note, .ed-hint { font-size: .78rem; color: var(--muted); line-height: 1.6; margin: 8px 0; }
.ed-sub { font-size: .85rem; font-weight: 700; margin: 14px 0 6px; }

/* デザイン一覧 */
.ed-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-chip {
  padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font: inherit; font-size: .82rem; cursor: pointer; color: var(--ink);
}
.ed-chip[aria-pressed="true"] { background: var(--ai); border-color: var(--ai); color: #fff; font-weight: 700; }
.tmpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tmpl-thumb {
  padding: 0; border: 2px solid transparent; border-radius: 6px; background: #fff; cursor: pointer;
  overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.12); transition: transform .12s, border-color .12s;
}
.tmpl-thumb img { width: 100%; height: auto; display: block; }
.tmpl-thumb:hover { transform: translateY(-2px); border-color: #9bb6d6; }
.tmpl-thumb.active { border-color: var(--ai); box-shadow: 0 0 0 2px var(--ai-soft), 0 2px 8px rgba(31,58,95,.25); }
.tmpl-thumb[hidden] { display: none; }

/* 文字タブ */
.ed-bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-bigbtn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
  font: inherit; font-size: .85rem; font-weight: 700; color: var(--ink);
}
.ed-bigbtn:hover { border-color: var(--ai); background: var(--ai-soft); }
.ed-bigbtn-ico {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  background: var(--ai); color: #fff; font-family: var(--mincho); font-size: 1.2rem;
}
.ed-phrases { display: flex; flex-direction: column; gap: 6px; }
.phrase-btn {
  text-align: left; padding: 8px 12px; border: 1px dashed #b7c7da; border-radius: 6px; background: #fbfcfe;
  font-family: var(--mincho); font-size: .9rem; color: var(--ink); cursor: pointer;
}
.phrase-btn:hover { border-style: solid; border-color: var(--ai); background: var(--ai-soft); }

/* 差出人 */
.ed-sender { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.ed-sender .ed-label span { font-weight: 400; }
.ed-sender input, .ed-sender textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .9rem;
}
.ed-sender textarea { resize: vertical; line-height: 1.6; }
.ed-sender .ed-primary { margin-top: 12px; background: var(--ai); }
.ed-sender .ed-primary:hover { background: #152a45; }

/* 写真タブ */
.ed-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 26px 12px;
  border: 2px dashed #9bb6d6; border-radius: 10px; background: #f7faff; cursor: pointer;
  font: inherit; color: var(--ai);
}
.ed-drop:hover, .ed-app.is-dragover .ed-drop { background: var(--ai-soft); border-color: var(--ai); }
.ed-drop-ico { font-size: 2rem; line-height: 1; }
.ed-drop span:last-child { font-size: .78rem; color: var(--muted); }

/* AI タブ（フォームの見た目） */
#pane-ai .form-label { display: block; font-weight: 700; font-size: .85rem; margin: 0 0 4px; }
#pane-ai .mb-3 { margin-bottom: 12px; }
.ed-radios { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.radio-label {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer; font-size: .82rem; background: #fff;
}
.radio-label:has(input:checked) { border-color: var(--ai); background: var(--ai-soft); font-weight: 700; }
.radio-label input { accent-color: var(--ai); margin: 0; }
#pane-ai textarea, #pane-ai select { width: 100%; font: inherit; font-size: .9rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.ai-result-box {
  background: #fff; border: 1px dashed var(--ai); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
  white-space: pre-wrap; font-size: .88rem; line-height: 1.9; max-height: 180px; overflow-y: auto;
}
.ed-error { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: #fdecec; color: #a12b2b; font-size: .85rem; }

/* 中央：はがき */
.ed-stage { display: flex; flex-direction: column; align-items: center; min-width: 0; width: 100%; }
.ed-stagebar { display: flex; gap: 6px; width: 100%; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
#canvas-wrapper {
  position: relative; background: #fff; box-shadow: 0 6px 24px rgba(31,58,95,.18); overflow: hidden;
}
#canvas-spinner {
  position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,.8); color: var(--muted); font-size: .9rem;
}
.ed-stagehint { font-size: .78rem; color: var(--muted); margin: 10px 0 0; text-align: center; }

/* ボタン */
.ed-tool {
  display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font: inherit; font-size: .82rem; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.ed-tool:hover:not(:disabled) { border-color: var(--ai); color: var(--ai); }
.ed-tool:disabled { opacity: .45; cursor: default; }
.ed-tool[aria-pressed="true"] { background: var(--ai); border-color: var(--ai); color: #fff; }
.ed-tool-danger { color: #b33a3a; }
.ed-tool-danger:hover:not(:disabled) { border-color: #b33a3a; color: #b33a3a; background: #fdf1f1; }
.ed-tool-save { background: #1d7a4a; border-color: #1d7a4a; color: #fff; font-weight: 700; }
.ed-tool-save:hover:not(:disabled) { background: #16613a; border-color: #16613a; color: #fff; }
.ed-primary, .ed-secondary, .ed-line {
  display: block; width: 100%; padding: 12px; border: 0; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer;
}
.ed-primary { background: #1d7a4a; color: #fff; font-size: 1rem; }
.ed-primary:hover { background: #16613a; }
.ed-primary:disabled { background: #9aa; }
#pane-ai .ed-primary { background: var(--ai); }
#pane-ai .ed-primary:hover { background: #152a45; }
.ed-secondary { background: #fff; color: var(--ai); border: 1px solid var(--ai); }
.ed-secondary:hover { background: var(--ai-soft); }
/* AI文章の挿入：今のデザインの向き（縦書き・横書き）のボタンを塗りつぶして勧める */
.ed-insert { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed-insert .ed-secondary { padding: 10px 4px; font-size: .88rem; }
.ed-insert .is-recommended { background: var(--ai); color: #fff; }
.ed-insert .is-recommended:hover { background: #152a45; }
.ed-line { background: #06c755; color: #fff; margin-top: 12px; }
.ed-line:hover { background: #05a647; }
.ed-link { border: 0; background: none; padding: 0; color: var(--ai); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; text-decoration: underline; }

/* 右：選んだものの編集 */
.ed-inspector { padding: 14px; margin-bottom: 12px; }
.ed-empty { font-size: .82rem; color: var(--muted); }
.ed-empty p { margin: 0 0 8px; }
.ed-empty-title { font-weight: 700; color: var(--ink); font-size: .9rem; }
.ed-ctx[hidden], .ed-ctx-common[hidden], .ed-empty[hidden] { display: none; }
.ed-label { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.ed-ctx > .ed-label:first-child { margin-top: 0; }
#obj-text {
  width: 100%; min-height: 84px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mincho); font-size: .95rem; line-height: 1.7; resize: vertical;
}
#obj-text:focus, #font-select:focus { outline: 2px solid var(--ai-soft); border-color: var(--ai); }
#font-select { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .88rem; background: #fff; }
.ed-size { display: flex; align-items: center; gap: 8px; }
.ed-size input[type=range] { flex: 1; accent-color: var(--ai); }
.ed-size input[type=number] { width: 64px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .88rem; }
.ed-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ai); }
.swatch-custom { position: relative; overflow: hidden; background: conic-gradient(#e44, #ec4, #4c6, #4ae, #a4e, #e44); }
.swatch-custom input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }
.ed-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.ed-ctx-common .ed-row { border-top: 1px solid var(--line); padding-top: 12px; }
.ed-shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ed-shape {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border: 1px solid var(--line);
  border-radius: 6px; font-size: .75rem; cursor: pointer;
}
.ed-shape input { position: absolute; opacity: 0; pointer-events: none; }
.ed-shape:has(input:checked) { border-color: var(--ai); background: var(--ai-soft); font-weight: 700; }
.ed-shape-ico { width: 28px; height: 22px; background: #8fb3d9; }
.ed-shape-frame { outline: 3px solid #fff; box-shadow: 0 0 0 4px #c9d6e4; }
.ed-shape-plain { border-radius: 0; }
.ed-shape-round { border-radius: 6px; }
.ed-shape-circle { width: 24px; height: 24px; border-radius: 50%; }

/* 保存 */
.ed-save { padding: 14px; }
.ed-save-title { font-weight: 700; margin: 0 0 8px; font-size: .9rem; }
.send-format { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: .78rem; }
.send-format label { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.send-format label:has(input:checked) { border-color: #06c755; background: #eafbf0; }
.send-format input { accent-color: #06c755; margin: 0 4px 0 0; }

/* 右下の小さなはがき（スマホ・タブレットだけ。JS が出し入れする） */
.ed-mini {
  position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 95;
  width: 104px; padding: 4px 4px 0; border: 0; border-radius: 8px; background: #fff; cursor: pointer;
  box-shadow: 0 4px 18px rgba(20,60,110,.35); font: inherit;
  opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity .2s, transform .2s, visibility .2s;
}
.ed-mini[hidden] { display: none; }
.ed-mini.show { opacity: 1; visibility: visible; transform: none; }
.ed-mini canvas { display: block; width: 96px; height: auto; border-radius: 3px; background: #f3f5f8; }
.ed-mini-label { display: block; padding: 3px 0 4px; font-size: .7rem; font-weight: 700; color: var(--ai); text-align: center; }
body.ed-mini-on .to-top { display: none; }

/* タブレット：左にタブ、右にはがき。編集と保存ははがきの下 */
@media (max-width: 999px) {
  .ed-app { grid-template-columns: 280px minmax(0, 1fr); grid-template-areas: "panel stage" "panel side"; }
  .ed-panel { position: sticky; top: 76px; display: flex; flex-direction: column; max-height: calc(100vh - 92px); }
  .ed-pane { overflow-y: auto; }
}
/* スマホ：はがき → 編集 → タブ → 保存 */
@media (max-width: 699px) {
  .ed-title { font-size: 1.1rem; }
  .ed-lead { font-size: .82rem; }
  .ed-app { display: flex; flex-direction: column; gap: 12px; padding: 12px 10px; }
  .ed-side { display: contents; }
  .ed-app > :not(.ed-mini), .ed-inspector, .ed-save { min-width: 0; width: 100%; }
  .ed-stage { order: 1; }
  .ed-inspector { order: 2; margin: 0; }
  .ed-panel { order: 3; position: static; max-height: none; }
  .ed-pane { overflow: visible; }
  .ed-save { order: 4; }
  .tmpl-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 360px; overflow-y: auto; }
  .ed-stagehint { display: none; }
}
