:root {
  --bg: #0b0b14;
  --panel: #151524;
  --line: #2a2a40;
  --text: #f2f2fa;
  --muted: #8a8aa6;
  --accent: #3cf2ff;
  --accent2: #ff3fa4;
  --radius: 14px;
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  background-image: radial-gradient(circle at 10% 0%, #2a0f3a 0, transparent 40%),
                    radial-gradient(circle at 90% 10%, #0f2a3a 0, transparent 40%);
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); font-size: 13px; }

/* header */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: rgba(11,11,20,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand { margin: 0; }
.brand .logo { height: 40px; width: auto; filter: drop-shadow(0 0 6px rgba(60,242,255,.5)); }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: .1em; }
.brand .title16 { font-size: 22px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; color: transparent; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.field span { font-size: 10px; color: var(--muted); letter-spacing: .1em; }
.field input { background: none; border: 0; outline: 0; width: 130px; }
select.field { appearance: none; cursor: pointer; }
button, .btn { border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.primary { background: linear-gradient(90deg, var(--accent2), #a44bff); color: #fff; }
.primary:disabled { opacity: .4; cursor: default; }
.ghost { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.icon { background: none; padding: 6px 10px; font-size: 18px; color: var(--muted); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 20px; max-width: 1100px; margin: 0 auto; }
@media (max-width: 760px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px; } }
.card {
  position: relative; background: var(--panel); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 0 18px -4px var(--c); }
.card .art { aspect-ratio: 1; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 12%, transparent); }
.card .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .plus { font-size: 34px; color: var(--c); opacity: .7; text-align: center; line-height: 1; }
.card .plus small { display: block; font-size: 11px; margin-top: 4px; }
.card .meta { padding: 8px 10px 10px; min-height: 62px; }
.card .area { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--c); }
.card .sub { font-size: 10px; color: var(--muted); min-height: 15px; }
.card .song { font-size: 14px; font-weight: 700; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .song.empty { color: var(--muted); font-weight: 400; }
.card .clear { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; width: 26px; height: 26px; padding: 0; justify-content: center; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  width: min(520px, 94vw); max-height: 86vh; }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
#picker[open], #result[open] { display: flex; flex-direction: column; gap: 10px; }
.pk-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pk-head h2 { margin: 0; font-size: 18px; }
#pkSearch { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: 0; }
#pkSearch:focus { border-color: var(--accent); }
.pk-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.pk-list li { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; }
.pk-list li:hover, .pk-list li.sel { background: #22223a; }
.pk-list li.used { opacity: .35; }
.pk-list img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--bg); flex: none; }
.pk-list .t { font-weight: 700; font-size: 14px; }
.pk-list .a { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.pk-list .tag { font-size: 10px; color: var(--accent2); margin-left: 6px; }
#resultImg { width: 100%; border-radius: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #000; padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 10; }

.card .art { position: relative; }
.card .area { display: flex; align-items: center; gap: 4px; }
.card .am-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 30px; margin-top: 8px; }
.card .am { display: block; height: 30px; line-height: 0; flex: none; }
.card .am img { display: block; height: 30px; width: auto; }
.foot a { color: var(--muted); }

.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--g); z-index: 1; }
.card:hover { box-shadow: 0 0 18px -4px var(--c), 0 0 2px var(--c); }
.brand .title16 { display: none; }


/* ヘッダー: 電音部ロゴ＋モード名、モード切替 */
.brand { gap: 14px; flex-wrap: wrap; }
.brand h1 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: inherit; }
.brand .logo { height: 36px; }
.mode-label { font-size: 22px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.modes { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.modes button { background: none; color: var(--muted); padding: 5px 14px; }
.modes button.on { background: linear-gradient(90deg, var(--accent2), #a44bff); color: #fff; }
.card.anthem::after { content: "♪"; position: absolute; top: 10px; left: 12px; color: rgba(255,255,255,.5); font-size: 14px; }

#pkTitle { display: flex; align-items: center; gap: 10px; }

/* ヘッダーの入力欄とボタンの高さ・余白をそろえる */
.controls { gap: 8px; }
.controls > * { height: 36px; }
.field { padding: 0 14px; gap: 8px; }
.field .fl { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .12em; white-space: nowrap; }
.field input { width: 120px; font-size: 13px; }
.field input::placeholder { color: #55556e; }
.field.sel { position: relative; padding-right: 30px; }
.field.sel::after { content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.field select { appearance: none; background: none; border: 0; outline: 0; font-size: 13px; cursor: pointer; max-width: 170px; }
.field select option { color: #000; }
.field:focus-within { border-color: var(--accent); }
.controls button { padding: 0 16px; }

.modes button { font-size: 11px; letter-spacing: .1em; }

.card .area { min-height: 22px; }
.card .art { overflow: hidden; }
.card .art > img { position: absolute; inset: 0; width: 100%; height: 100%; }

.pk-sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* 選曲ダイアログ */
.pk-count { margin-left: auto; color: var(--muted); font-size: 13px; }
.pk-count b { font-size: 26px; font-weight: 800; color: var(--text); margin-right: 2px; }
.pk-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.pk-filters .field { height: 34px; flex: 1; min-width: 0; }
.pk-filters .field select { max-width: none; width: 100%; }
.pk-filters [hidden] { display: none; }

/* 共有URLを開いたときの「見るだけ」表示 */
.view-banner { max-width: 1100px; margin: 16px auto 0; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.view-banner[hidden] { display: none; }
.view-banner p { margin: 0; font-size: 16px; }
.view-banner b { font-size: 18px; }
.vb-mode { display: block; font-size: 11px; color: var(--muted); letter-spacing: .08em; margin-top: 2px; }
body.viewing .controls .field, body.viewing .modes, body.viewing #btnGen, body.viewing #btnReset { display: none; }
body.viewing .card { cursor: default; }
body.viewing .card:hover { transform: none; }
@media (max-width: 760px) { .view-banner { margin: 12px 12px 0; } }
body.viewing .plus { visibility: hidden; }

/* ランキング */
#rank { width: min(760px, 94vw); }
#rank[open] { display: flex; flex-direction: column; gap: 10px; }
.rank-body { overflow: auto; }
.rank-body h3 { font-size: 14px; letter-spacing: .08em; margin: 18px 0 8px; color: var(--muted); }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 8px; }
.rank-list li:nth-child(-n+3) .rk { color: var(--accent2); }
.rank-list .rk { width: 22px; text-align: right; font-weight: 800; font-size: 15px; }
.rank-list img { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; }
.rank-list .rt { flex: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.rank-areas section { background: var(--bg); border-radius: 10px; padding: 10px; position: relative; overflow: hidden; }
.rank-areas section::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--g); }
.rank-areas h4 { margin: 0 0 6px; font-size: 12px; color: var(--c); letter-spacing: .06em; }
.rank-areas h4 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.rank-list.mini img { width: 28px; height: 28px; }
.rank-list.mini .rt { font-size: 12px; }
.rank-note { margin: 0; font-size: 11px; }
.rank-upd { font-size: 11px; margin-top: 14px; }

/* ANTHEM 枠のドラッグ＆ドロップ */
.card.anthem .art img { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.card.dragging { opacity: .35; }
.card.drop-target { outline: 2px dashed var(--accent); outline-offset: 3px; transform: scale(1.02); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; border-radius: 10px; object-fit: cover;
  box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 0 2px var(--accent); opacity: .92; }
