:root {
  --accent: #0fb8ac;
  --accent-dark: #0a8f86;
  --navy: #232838;
  --navy-light: #2e3448;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e1e5ea;
  --text: #29303d;
  --text-mute: #737c8c;
  --danger: #e0554f;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ===== Top bar ===== */
.topbar {
  height: 56px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 700; font-size: 18px; }
.logo-accent { color: var(--accent); }
.ea-name-input {
  background: var(--navy-light);
  border: 1px solid #444b5e;
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  width: 200px;
}
.platform-select {
  background: var(--navy-light);
  border: 1px solid #444b5e;
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 14px;
}
.topbar-right { display: flex; gap: 8px; }

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #3d78e0; color: #fff; }
.btn-secondary:hover { background: #2f61bd; }
.btn-ghost { background: transparent; color: #d8dce5; border: 1px solid #4b5266; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-outline { background: #fff; color: var(--accent-dark); border: 1px solid var(--accent); }
.btn-unlock { background: #b8890f; color: #fff; }
.btn-unlock:hover { background: #96700c; }

/* ===== ロック関連 ===== */
.lock-badge { margin-left: 6px; font-size: 11px; }
.lock-badge:not(:empty)::before { content: ''; }
.template-card.is-locked { opacity: .8; background: #faf8f2; border-color: #e8dcc0; }
.lock-hint { display: block; font-size: 12px; color: #a3760f; margin-bottom: 10px; }
.locked-panel {
  background: #fffaf0; border: 1px dashed #d9b775; border-radius: var(--radius);
  padding: 32px; text-align: center; color: var(--text);
}
.locked-panel .lock-icon { font-size: 32px; margin-bottom: 8px; }
.locked-panel p { color: var(--text-mute); max-width: 480px; margin: 8px auto 18px; font-size: 13px; line-height: 1.7; }

/* ===== Layout ===== */
.body-layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 210px;
  background: var(--navy);
  color: #cfd3dd;
  flex-shrink: 0;
  overflow-y: auto;
  padding-bottom: 20px;
}
.menu-group-label {
  font-size: 12px;
  color: #7d8496;
  padding: 16px 16px 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.menu { list-style: none; margin: 0; padding: 0; }
.menu li {
  padding: 12px 18px;
  cursor: pointer;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.menu li:hover { background: var(--navy-light); }
.menu li.active {
  background: var(--navy-light);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.panel-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}
.panel-desc { color: var(--text-mute); font-size: 13px; margin: 0 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; color: var(--navy); }

.field-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.field-row label { width: 160px; flex-shrink: 0; font-size: 13px; color: var(--text); }
.field-row .hint { font-size: 12px; color: var(--text-mute); margin-left: 8px; }
.field-row input[type=text],
.field-row input[type=number],
.field-row select,
.field-row textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  width: 220px;
}
.field-row textarea { width: 400px; min-height: 60px; }
.field-row input[type=checkbox] { width: 16px; height: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }

.toggle-card { border-left: 4px solid var(--border); }
.toggle-card.on { border-left-color: var(--accent); }

/* ===== Condition builder ===== */
.subtabs { display: flex; gap: 4px; margin-bottom: 16px; }
.subtabs button {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
}
.subtabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.pattern-list { display: flex; flex-direction: column; gap: 0; }
.pattern-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 4px;
}
.pattern-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pattern-head h4 { margin: 0; font-size: 14px; color: var(--navy); }
.or-divider {
  text-align: center;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 12px;
  margin: 6px 0;
}
.condition-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
}
.condition-row .cond-text { font-family: Consolas, monospace; }
.condition-row .cond-actions { display: flex; gap: 6px; }
.and-divider { text-align: center; color: var(--text-mute); font-size: 11px; margin: 2px 0; }
.link { color: var(--accent-dark); cursor: pointer; font-size: 13px; font-weight: 600; }
.link.danger { color: var(--danger); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,24,32,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: #fff; border-radius: 10px; width: 640px; max-width: 92vw;
  max-height: 88vh; overflow-y: auto; padding: 24px 28px;
}
.modal-box h3 { margin-top: 0; }
.modal-box p.lead { color: var(--text-mute); font-size: 13px; margin-top: -8px; }

.template-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.template-card h4 { margin: 0 0 6px; font-size: 15px; color: var(--navy); }
.template-card p { margin: 0 0 12px; font-size: 13px; color: var(--text-mute); line-height: 1.6; }
.template-card .tpl-detail { font-size: 12px; color: var(--accent-dark); font-family: Consolas, monospace; margin-bottom: 12px; }
.side-box { border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.side-box h5 { margin: 0 0 10px; font-size: 13px; color: var(--accent-dark); }
.op-select-wrap { text-align: center; padding: 10px 0; }
.op-select-wrap select { font-size: 14px; font-weight: 700; padding: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ===== EA list ===== */
table.ea-table { width: 100%; border-collapse: collapse; background: #fff; }
table.ea-table th, table.ea-table td {
  border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; font-size: 13px;
}
table.ea-table th { color: var(--text-mute); font-weight: 600; }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 20px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .25s;
  z-index: 200;
}
#toast.show { opacity: 1; }


/* =====================================================
   EA BUILDER - site header / footer
===================================================== */

.site-mini-header {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #e5e8ec;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.site-brand {
  color: #181c25;
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
}

.back-blog {
  color: #566071;
  font-size: 13px;
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid #dce1e7;
  border-radius: 6px;
}

.back-blog:hover {
  background: #f4f6f8;
}


/* Footer */

.ea-footer {
  background: #202533;
  color: #aeb5c3;
  text-align: center;
  padding: 22px 20px;
  font-size: 12px;
}

.ea-footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  margin-bottom: 12px;
}

.ea-footer-nav a {
  color: #d9dde5;
  text-decoration: none;
}

.ea-footer-nav a:hover {
  color: #fff;
}

/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 768px) {

  body {
    overflow-x: hidden;
  }

  #app {
    height: auto;
    min-height: 100vh;
  }


  /* サイトヘッダー */

  .site-mini-header {
    height: 48px;
    padding: 0 14px;
  }

  .site-brand {
    font-size: 14px;
  }

  .back-blog {
    font-size: 11px;
    padding: 6px 8px;
  }


  /* EA Builder ヘッダー */

  .topbar {
    height: auto;
    padding: 12px;
    display: block;
  }

  .topbar-left {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .logo {
    grid-column: 1 / -1;
    font-size: 18px;
    margin-bottom: 3px;
  }

  .ea-name-input {
    width: 100%;
    min-width: 0;
  }

  .platform-select {
    width: auto;
  }


  /* 操作ボタン */

  .topbar-right {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .topbar-right .btn {
    width: 100%;
    padding: 9px 5px;
    font-size: 12px;
  }

  /* EA作成を最重要ボタンとして全面表示 */

  #btnGenerate {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 12px 10px;
    font-size: 14px;
  }

  #btnUnlock {
    grid-column: 1 / -1;
  }


  /* 左サイドバーを上部タブ化 */

  .body-layout {
    display: block;
  }

  .sidebar {
    width: 100%;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    position: sticky;
    top: 0;
    z-index: 50;
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .menu-group-label {
    display: none;
  }

  .menu {
    display: flex;
    width: max-content;
  }

  .menu li {
    flex: none;
    border-left: 0;
    border-bottom: 3px solid transparent;
    padding: 11px 15px;
    white-space: nowrap;
    font-size: 12px;
  }

  .menu li.active {
    border-left: 0;
    border-bottom-color: var(--accent);
  }

  /* 本文 */

  .content {
    padding: 18px 12px 40px;
    overflow-y: visible;
  }

  .panel-title {
    font-size: 19px;
  }

  .panel-desc {
    line-height: 1.7;
  }


  /* カード */

  .card {
    padding: 16px 14px;
    margin-bottom: 14px;
  }


  /* 2列 → 1列 */

  .grid2 {
    grid-template-columns: 1fr;
    gap: 0;
  }


  /* 入力項目を縦並び */

  .field-row {
    display: block;
    margin-bottom: 18px;
  }

  .field-row label {
    display: block;
    width: auto;
    margin-bottom: 6px;
    font-weight: 600;
  }

  .field-row input[type=text],
  .field-row input[type=number],
  .field-row select,
  .field-row textarea {
    width: 100%;
    max-width: 100%;
    font-size: 16px;
    padding: 10px;
  }

  .field-row textarea {
    min-height: 90px;
  }

  .field-row .hint {
    display: block;
    margin: 6px 0 0;
    line-height: 1.5;
  }


  /* サブタブ */

  .subtabs {
    overflow-x: auto;
    white-space: nowrap;
  }

  .subtabs button {
    flex: none;
  }


  /* 条件 */

  .condition-row {
    align-items: flex-start;
    gap: 8px;
  }

  .condition-row .cond-text {
    word-break: break-word;
    overflow-wrap: anywhere;
  }


  /* モーダル */

  .modal-overlay {
    align-items: flex-end;
  }

  .modal-box {
    width: 100%;
    max-width: none;
    max-height: 90vh;
    border-radius: 14px 14px 0 0;
    padding: 20px 16px;
  }


  /* EA一覧 */

  table.ea-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  table.ea-table th,
  table.ea-table td {
    padding: 9px 5px;
    font-size: 11px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  table.ea-table th:nth-child(1),
  table.ea-table td:nth-child(1) {
    width: 38%;
  }

  table.ea-table th:nth-child(2),
  table.ea-table td:nth-child(2) {
    width: 12%;
  }

  table.ea-table th:nth-child(3),
  table.ea-table td:nth-child(3) {
    width: 25%;
  }

  table.ea-table th:nth-child(4),
  table.ea-table td:nth-child(4) {
    width: 25%;
  }
  
  /* footer */

  .ea-footer {
    padding: 20px 12px;
  }

  .ea-footer-nav {
    gap: 10px 16px;
    font-size: 11px;
  }
}

/* ===== ロック解除・メルマガ登録モーダル ===== */
.unlock-modal {
  width: 520px;
}

.unlock-modal__head h3 {
  margin-bottom: 12px;
}

.unlock-register {
  background: #f8fbfc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-top: 18px;
}

.unlock-register h4 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--navy);
}

.unlock-register__desc {
  margin: 0 0 14px;
  color: var(--text-mute);
  font-size: 12px;
  line-height: 1.7;
}

.unlock-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.unlock-email,
#unlockCodeInput {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 11px 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.unlock-email:focus,
#unlockCodeInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 184, 172, .12);
}

.unlock-register__submit {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  font-size: 15px;
}

.unlock-register__note {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-mute);
}

.unlock-terms {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-mute);
}

.unlock-terms summary,
.unlock-existing summary {
  cursor: pointer;
  user-select: none;
}

.unlock-terms summary {
  text-decoration: underline;
}

.unlock-terms__content {
  margin-top: 9px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 7px;
  line-height: 1.7;
}

.unlock-terms__content h5 {
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--text);
}

.unlock-terms__content ol {
  margin: 4px 0 8px;
  padding-left: 20px;
}

.unlock-terms__content p {
  margin: 4px 0;
}

.unlock-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
  color: var(--text-mute);
  font-size: 12px;
}

.unlock-divider::before,
.unlock-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.unlock-existing {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.unlock-existing > summary {
  padding: 11px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
}

.unlock-existing__body {
  padding: 0 13px 14px;
}

.unlock-existing__body .btn {
  width: 100%;
  margin-top: 10px;
}

.unlock-error {
  color: var(--danger);
  margin: 7px 0 0;
}

.unlock-modal__actions {
  margin-top: 14px;
}

@media (max-width: 768px) {
  .unlock-modal {
    width: 100%;
  }

  .unlock-register {
    padding: 15px 13px;
  }

  .unlock-modal__actions .btn {
    width: 100%;
  }
}

/* ===== 動画解説 ===== */
.video-card { padding: 16px; }
.video-card h3 { margin: 0 0 12px; }
.video-embed {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
@media (max-width: 600px) {
  .video-embed {
    max-width: 100%;
  }
}
.video-embed .video-thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.video-embed .video-play-btn {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: 2px solid rgba(255,255,255,.85);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.video-embed iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
