/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Base
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
* { margin: 0; padding: 0; box-sizing: border-box; }
button { touch-action: manipulation; }

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.7;
  overflow-x: hidden;
}

header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header-inner { max-width: 800px; margin: 0 auto; padding: 0 1.5rem; }
.logo { font-size: 1.2rem; font-weight: bold; color: #1a73e8; text-decoration: none; }

main { max-width: 800px; margin: 2rem auto; padding: 0 1.5rem; }

h1 { font-size: 1.8rem; font-weight: bold; margin-bottom: .5rem; }
h2 { font-size: 1.2rem; font-weight: bold; margin-bottom: 1rem; }
.description { color: #666; margin-bottom: 1.5rem; }
.section-note { font-size: .85rem; color: #888; margin-bottom: 1rem; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e0e0e0;
}
.hidden { display: none !important; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ヒーロー
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.hero {
  text-align: center;
  padding: 28px 0 20px;
  margin-bottom: 1.5rem;
}
.hero-icon { font-size: 3rem; margin-bottom: 10px; }
.hero h1 { font-size: 1.8rem; font-weight: bold; margin-bottom: 6px; color: #1e293b; }
.hero .description { color: #666; font-size: .95rem; line-height: 1.7; margin-bottom: 0; }
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.badge {
  display: inline-block;
  padding: 5px 13px;
  background: #dbeafe;
  color: #1a73e8;
  border: 1.5px solid #bfdbfe;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   クラッシュ回復バナー
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.recovery-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: #fff7ed;
  border: 1.5px solid #fdba74;
  border-radius: 10px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  font-size: .88rem;
  color: #9a3412;
}
.recovery-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #9a3412;
  flex-shrink: 0;
  padding: 0 .25rem;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ドキュメントタブ
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.tabs-card { padding: .6rem .9rem; }
.doc-tabs {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  min-height: 36px;
}
.doc-tab {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .38rem .8rem;
  border-radius: 8px;
  border: 1.5px solid #e0e0e0;
  background: #fff;
  cursor: pointer;
  font-size: .85rem;
  color: #555;
  transition: all .15s;
  user-select: none;
}
.doc-tab.active {
  border-color: #1a73e8;
  background: #f0f6ff;
  color: #1a73e8;
  font-weight: 600;
}
.doc-tab:hover:not(.active) { border-color: #bbb; background: #fafafa; }
.doc-tab-name { cursor: pointer; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-tab-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .72rem;
  color: #bbb;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.doc-tab-del:hover { color: #e53e3e; }
.doc-tab-new {
  padding: .38rem .7rem;
  border-radius: 8px;
  border: 1.5px dashed #d0d0d0;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: #bbb;
  transition: all .15s;
  line-height: 1;
}
.doc-tab-new:hover { border-color: #1a73e8; color: #1a73e8; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   エディタ
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.editor-card { padding: 0; overflow: hidden; }

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
}
.tool-btn {
  padding: .42rem .8rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  background: #fff;
  color: #444;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.tool-btn:hover { border-color: #1a73e8; color: #1a73e8; background: #f0f6ff; }
.snap-btn:hover { border-color: #7c3aed; color: #7c3aed; background: #f5f3ff; }
.install-btn { border-color: #059669; color: #059669; }
.install-btn:hover { background: #ecfdf5; border-color: #059669; color: #059669; }

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: #e0e0e0;
  flex-shrink: 0;
  margin: 0 .1rem;
}
.font-size-group { display: flex; align-items: center; gap: .4rem; }
.font-label { font-size: .78rem; color: #888; white-space: nowrap; }
.font-btns { display: flex; gap: .2rem; }
.font-btn {
  padding: .3rem .55rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  color: #888;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.font-btn:hover  { border-color: #1a73e8; color: #1a73e8; }
.font-btn.active { border-color: #1a73e8; background: #1a73e8; color: #fff; }

.editor-stats {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem 1rem;
  background: #f8fbff;
  border-bottom: 1px solid #f0f0f0;
  font-size: .8rem;
  color: #888;
}
.stat-sep { color: #ddd; }

#editor {
  display: block;
  width: 100%;
  min-height: 380px;
  padding: 1rem 1.1rem;
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.85;
  color: #1e293b;
  background: #fff;
  border: none;
  resize: vertical;
  tab-size: 2;
  outline: none;
}
#editor::placeholder { color: #c0cdd8; }
#editor:focus { background: #fff; }

.editor-status {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .45rem 1rem;
  background: #fafbfc;
  border-top: 1px solid #f0f0f0;
  font-size: .78rem;
  flex-wrap: wrap;
}
.status-saved  { color: #16a34a; font-weight: 600; }
.status-saving { color: #d97706; font-weight: 600; }
.status-error  { color: #dc2626; font-weight: 600; }
.last-saved-time { color: #999; }
.storage-info { color: #bbb; margin-left: auto; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   送信先テンプレート
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .85rem;
  border: 1px solid #e8f0fe;
  border-radius: 10px;
  background: #f8fbff;
  margin-bottom: .5rem;
}
.tpl-info { flex: 1; min-width: 0; }
.tpl-name { font-size: .9rem; font-weight: 600; color: #1e293b; display: block; }
.tpl-note-text { font-size: .78rem; color: #888; }
.tpl-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.tpl-open-btn {
  padding: .38rem .7rem;
  border: 1.5px solid #1a73e8;
  border-radius: 7px;
  background: #f0f6ff;
  color: #1a73e8;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s;
}
.tpl-open-btn:hover { background: #1a73e8; color: #fff; }
.tpl-del-btn {
  padding: .38rem .55rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  background: #fff;
  color: #aaa;
  font-size: .78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.tpl-del-btn:hover { border-color: #e53e3e; color: #e53e3e; background: #fff5f5; }
.no-templates-msg { font-size: .85rem; color: #bbb; padding: .5rem 0; }

.add-tpl-details { margin-top: .75rem; }
.add-tpl-summary {
  font-size: .88rem;
  color: #1a73e8;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  list-style: none;
}
.add-tpl-summary::-webkit-details-marker { display: none; }
.add-tpl-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-top: .75rem;
  padding: .85rem;
  background: #f8fbff;
  border-radius: 10px;
  border: 1px solid #e8f0fe;
}
.add-tpl-form input[type="text"],
.add-tpl-form input[type="url"] {
  padding: .5rem .75rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  font-size: .88rem;
  font-family: inherit;
  background: #fff;
  color: #333;
  transition: border-color .15s;
}
.add-tpl-form input:focus { outline: none; border-color: #1a73e8; }
.add-tpl-form input[type="url"] { grid-column: 1 / -1; }
.tpl-add-btn {
  grid-column: 1 / -1;
  padding: .5rem;
  border: none;
  border-radius: 7px;
  background: #1a73e8;
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.tpl-add-btn:hover { background: #1557b0; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   バージョン履歴
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.history-header h2 { margin-bottom: 0; }
.clear-hist-btn {
  padding: .35rem .7rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  background: #fff;
  color: #aaa;
  font-size: .78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.clear-hist-btn:hover { border-color: #e53e3e; color: #e53e3e; background: #fff5f5; }

.history-list { display: flex; flex-direction: column; gap: .6rem; }
.no-history-msg { font-size: .85rem; color: #bbb; text-align: center; padding: 1.5rem 0; }

.history-item {
  border: 1px solid #e8edf5;
  border-radius: 10px;
  padding: .8rem 1rem;
  background: #fafbfc;
  transition: border-color .15s;
}
.history-item:hover { border-color: #c0d0f0; }

.history-item-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .4rem;
  flex-wrap: wrap;
}
.history-time {
  font-size: .82rem;
  font-weight: 600;
  color: #1a73e8;
}
.history-chars {
  font-size: .78rem;
  color: #999;
  background: #f0f0f0;
  padding: 1px 7px;
  border-radius: 10px;
}
.snap-label {
  font-size: .72rem;
  color: #7c3aed;
  background: #f5f3ff;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid #ddd6fe;
}
.history-preview {
  font-size: .82rem;
  color: #666;
  line-height: 1.5;
  margin-bottom: .55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-actions { display: flex; gap: .4rem; }
.hist-btn {
  padding: .32rem .65rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.restore-btn {
  border: 1.5px solid #1a73e8;
  background: #f0f6ff;
  color: #1a73e8;
}
.restore-btn:hover { background: #1a73e8; color: #fff; }
.delete-btn {
  border: 1.5px solid #e0e0e0;
  background: #fff;
  color: #aaa;
}
.delete-btn:hover { border-color: #e53e3e; color: #e53e3e; background: #fff5f5; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   活用シーン
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.scene-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  background: #f0f6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
}
.scene-icon { font-size: 1.7rem; flex-shrink: 0; }
.scene-body strong { display: block; font-size: .88rem; font-weight: 700; color: #1a56db; margin-bottom: .2rem; }
.scene-body p { font-size: .78rem; color: #4b5563; line-height: 1.55; margin: 0; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Amazon
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.amazon-card h2 { margin-bottom: .25rem; }
.amazon-note { font-size: .82rem; color: #999; margin-bottom: 1rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.amazon-item {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: .9rem;
  text-decoration: none;
  color: inherit;
  transition: border-color .2s, box-shadow .2s, transform .1s;
}
.amazon-item:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,.15);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.7rem; margin-bottom: .35rem; }
.amazon-item-name { font-size: .88rem; font-weight: bold; margin-bottom: .2rem; }
.amazon-item-desc { font-size: .76rem; color: #888; line-height: 1.5; margin-bottom: .45rem; }
.amazon-item-link { font-size: .78rem; color: #FF9900; font-weight: bold; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Tips
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item { display: flex; gap: .65rem; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; }
.tip-text strong { display: block; font-weight: 700; margin-bottom: .15rem; font-size: .88rem; }
.tip-text p { font-size: .8rem; color: #78716c; line-height: 1.55; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   FAQ
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #1a73e8; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   関連ツール
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.related-tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}
.related-tool-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  border: 1.5px solid #e8edf5;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover { border-color: #1a73e8; box-shadow: 0 2px 8px rgba(26,115,232,.1); }
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; }
.related-tool-item strong { display: block; font-size: .88rem; font-weight: 700; color: #1a73e8; margin-bottom: .2rem; }
.related-tool-item p { font-size: .76rem; color: #888; line-height: 1.5; margin: 0; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   フッター
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: .82rem;
  color: #a8a29e;
  border-top: 1px solid #e7e5e4;
  margin-top: auto;
}
footer a { color: #ea580c; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p + p { margin-top: .3rem; }
.amazon-notice { font-size: .72rem; color: #bbb; margin-top: .2rem; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   トースト
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(30,30,30,.9);
  color: #fff;
  padding: .55rem 1.25rem;
  border-radius: 8px;
  font-size: .88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   モバイル対応
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 640px) {
  main { margin: 1rem auto; padding: 0 .9rem; }
  .hero h1 { font-size: 1.4rem; }
  .hero .description { font-size: .88rem; }

  .editor-toolbar { gap: .3rem; }
  .tool-btn { font-size: .76rem; padding: .38rem .6rem; }
  .toolbar-sep { display: none; }

  #editor { min-height: 280px; font-size: 16px !important; }

  .add-tpl-form { grid-template-columns: 1fr; }
  .add-tpl-form input[type="url"] { grid-column: auto; }

  .scene-grid { grid-template-columns: 1fr; }
  .amazon-grid { grid-template-columns: 1fr; }
  .related-tools { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .template-item { flex-direction: column; align-items: flex-start; }
  .tpl-actions { width: 100%; justify-content: flex-end; }
}
