:root {
  --bg: #23263f;
  --nav: #2e3252;
  --panel: #2b2f4c;
  --raised: #3a3f66;
  --raised-hover: #464c7a;
  --line: #4b5180;
  --text: #f1f2fb;
  --muted: #a3a8c9;
  --green: #4fd1a5;
  --green-text: #0f3b2c;
  --accent: #7c83f2;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- ヘッダー ---------- */
.nav { display: flex; align-items: center; gap: 12px; padding: 14px 32px; background: var(--nav); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: 12px; }
/* AI棒のロゴ：サイトと同じく白いタイルに載せる */
.logo-tile { display: grid; place-items: center; background: #fff; height: 48px; padding: 0 14px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.logo-tile img { height: 28px; display: block; }
.brand-name { font-weight: 800; letter-spacing: .02em; }
.nav-item { text-decoration: none; padding: 9px 16px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.nav-item.active { background: var(--raised); color: var(--text); }
.spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-right: 8px; }
.me .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: #fff; border: 2px solid #fff; }

.btn { border: 0; border-radius: 10px; padding: 11px 20px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-green { background: var(--green); color: var(--green-text); }
.btn-green:hover:not(:disabled) { filter: brightness(1.07); }
.btn-muted { background: var(--raised); }
.btn-muted:hover { background: var(--raised-hover); }

/* ---------- 一覧 ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 32px 64px; }
.toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: transparent; padding: 9px 16px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--raised); color: var(--text); }
.search { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 10px; padding: 8px 14px; width: 300px; max-width: 100%; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; }
.search:focus-within { border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.card { display: block; text-decoration: none; background: var(--panel); border-radius: 14px; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.35); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; }
.thumb svg, .thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.online { position: absolute; left: 10px; bottom: 10px; background: rgba(15,17,32,.8); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.card-body { padding: 12px 14px 14px; }
.card-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.empty { text-align: center; margin-top: 18vh; color: var(--muted); }
.empty-bubble { display: inline-grid; place-items: center; width: 48px; height: 40px; background: #e5e7eb; color: #e11d48; border-radius: 8px; font-weight: 800; font-size: 22px; position: relative; }
.empty-bubble::after { content: ""; position: absolute; bottom: -6px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #e5e7eb; }
.empty-avatar { font-size: 44px; margin: 14px 0 8px; }
.empty a { color: var(--text); font-weight: 700; }

/* ---------- モーダル ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10,11,22,.7); display: grid; place-items: center; padding: 16px; z-index: 10; overflow-y: auto; }
.modal-bg[hidden], .modal[hidden] { display: none; }
.modal { background: var(--panel); border-radius: 18px; padding: 26px; width: min(560px, 100%); display: grid; gap: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-wide { width: min(1020px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 16px; }
.modal-head > :first-child { flex: 1; }
.modal h2 { margin: 0; font-size: 22px; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.close { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--text); }

.purpose { display: flex; text-align: left; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: var(--raised); cursor: pointer; }
.purpose:hover:not(:disabled) { background: var(--raised-hover); outline: 2px solid var(--green); }
.purpose:disabled { cursor: default; opacity: .55; }
.purpose-img { width: 38%; flex-shrink: 0; aspect-ratio: 8 / 5; overflow: hidden; background: #000; }
.purpose-img svg { width: 100%; height: 100%; display: block; }
.purpose-body { padding: 18px 20px; align-self: center; }
.purpose-body h3 { margin: 0 0 8px; font-size: 19px; }
.purpose-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.badge { font-size: 11px; background: var(--line); padding: 2px 8px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }

.tpl { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
.preview { border-radius: 14px; padding: 14px; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; }
.preview svg { width: 100%; height: 100%; }
.field-head { display: flex; justify-content: space-between; font-weight: 800; margin-bottom: 14px; }
.size-label { color: var(--muted); }
.theme-head { margin-top: 24px; }
.size-desc { margin: 14px 0 0; font-size: 13px; color: var(--text); background: var(--raised); padding: 10px 12px; border-radius: 10px; line-height: 1.6; }

/* スライダー */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; margin: 6px 0;
  background: linear-gradient(to right, var(--accent) 0 var(--pct, 0%), #e5e7eb var(--pct, 0%) 100%); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 5px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 5px solid var(--accent); }
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.ticks span { cursor: pointer; width: 0; display: flex; justify-content: center; white-space: nowrap; }
.ticks span:first-child { justify-content: flex-start; }
.ticks span:last-child { justify-content: flex-end; }
.ticks span.on { color: var(--text); font-weight: 800; }

.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.theme { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border-radius: 12px; border: 2px solid transparent;
  background: var(--raised); font-weight: 800; cursor: pointer; }
.theme:hover { background: var(--raised-hover); }
.theme.sel { border-color: var(--green); }
.swatch { display: flex; gap: 4px; padding: 5px; border-radius: 8px; border: 2px solid; }
.swatch i { width: 14px; height: 14px; border-radius: 4px; }

.modal-foot { display: flex; justify-content: space-between; gap: 12px; }
.field { display: grid; gap: 8px; font-weight: 700; color: var(--muted); font-size: 14px; }
.field input { border: 2px solid var(--line); background: var(--bg); border-radius: 10px; padding: 12px; font-size: 16px; outline: 0; }
.field input:focus { border-color: var(--accent); }
.summary { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: #fca5a5; margin: 0; font-size: 13px; }
#name-form { display: grid; gap: 18px; }

@media (max-width: 820px) {
  .nav { padding: 12px 16px; flex-wrap: wrap; }
  .brand-name, .me { display: none; }
  .page { padding: 16px; }
  .tpl { grid-template-columns: 1fr; }
  .purpose { flex-direction: column; }
  .purpose-img { width: 100%; }
  .toolbar { justify-content: stretch; }
  .search { width: 100%; }
}
