/* EMOtone シリーズと同じ質感（暗い背景・グラデーション・角丸のガラス風パネル）のまま、
   EMObeat は黄緑を主役にして別作品と分かるようにする。 */
:root {
  --bg: #090f0b;
  --surface: rgba(22, 34, 26, 0.74);
  --surface-strong: #15211a;
  --text: #eef8ea;
  --muted: #9fb6a2;
  --border: rgba(214, 255, 196, 0.09);
  --border-strong: rgba(214, 255, 196, 0.2);
  --accent: #b6f03c;      /* 主役の黄緑 */
  --accent-2: #f2f55a;    /* レモン */
  --accent-3: #2fd39a;    /* ミントグリーン */
  --on-accent: #0b1606;   /* 黄緑の上に乗せる文字 */
  --grad: linear-gradient(120deg, var(--accent-2), var(--accent) 45%, var(--accent-3));
  --chip: rgba(214, 255, 196, 0.06);
  --danger: #ff7a6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.6;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(182, 240, 60, 0.20), transparent 60%),
    radial-gradient(700px 480px at 95% 0%, rgba(47, 211, 154, 0.18), transparent 60%),
    radial-gradient(800px 600px at 50% 110%, rgba(242, 245, 90, 0.08), transparent 60%),
    var(--bg);
}

/* ヘッダー */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 8px;
  max-width: 1440px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 48px; height: 48px; filter: drop-shadow(0 6px 18px rgba(182, 240, 60, 0.4)); }
.logo { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: 0.04em; line-height: 1.1; }
.logo span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); }
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.tab.active { background: var(--grad); color: var(--on-accent); }

/* レイアウト */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px 40px; }
  .header { padding: 16px 16px 4px; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(12px);
}
#form { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
@media (max-width: 900px) { #form { position: static; max-height: none; } }
.panel-title { margin: 0 0 12px; font-size: 15px; letter-spacing: 0.08em; color: var(--muted); }

.row { display: flex; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field.grow { flex: 1; }
.field label, .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 7px 10px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#bpm, #beat-bpm { width: 90px; }

button { font: inherit; cursor: pointer; }
.primary {
  border: 0;
  border-radius: 999px;
  padding: 8px 18px;
  background: var(--grad);
  color: var(--on-accent);
  font-weight: 700;
}
.ghost-btn {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 16px;
  background: transparent;
  color: var(--text);
}
.ghost-btn:hover { border-color: var(--accent); }
.small { padding: 4px 12px; font-size: 13px; }
.playing { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(182, 240, 60, 0.55); }
.dragging { opacity: 0.6; }

/* セクションの入力 */
.sections-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 8px; }
.preset select { font-size: 12px; padding: 4px 8px; }
.sections { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.section-row { background: var(--chip); border: 1px solid var(--border); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.section-row-head { display: flex; gap: 6px; align-items: center; }
.sec-name { width: 88px; font-weight: 700; }
.sec-mood { flex: 1; font-size: 13px; }
.sec-bars { width: 54px; }
.unit { font-size: 12px; color: var(--muted); }
.row-buttons { display: flex; gap: 2px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 22px; padding: 0; font-size: 14px; }
.icon-btn:hover { color: var(--text); }
.sec-chords { font-size: 13px; font-family: "Cascadia Code", Consolas, monospace; }

/* 狭い幅でもはみ出さないように */
#form { overflow-x: hidden; }
.row .field { min-width: 0; }
.row select { width: 100%; }
.section-row-head { flex-wrap: wrap; }
.sec-name { flex: 1 1 88px; }
.sec-mood { flex: 1 1 120px; }

.guide { margin-top: 12px; font-size: 12px; color: var(--muted); }
.guide summary { cursor: pointer; font-weight: 600; }
.guide ul { padding-left: 18px; margin: 6px 0 0; }
.guide code { color: var(--text); background: var(--chip); padding: 1px 5px; border-radius: 4px; }

.status { min-height: 1.2em; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.status.error { color: var(--danger); }

/* 結果 */
.result { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.transport { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
.song-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.song-info .big { font-weight: 800; font-size: 18px; }
.transport-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); padding: 0 4px; }
.legend-item::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--c, rgba(255, 255, 255, 0.6));
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag.mood { color: var(--text); border-color: var(--accent); }
.tag.manual { color: var(--accent-2); border-color: var(--accent-2); }
.tag.hit { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.tag.genre { color: var(--accent-3); }

.song, .beat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  animation: rise 0.35s ease both;
  min-width: 0;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card-title h3 { margin: 0; font-size: 18px; }
.card-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

/* ドラムのグリッド */
.grid-wrap { overflow-x: auto; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border); }
.grid { position: relative; padding: 6px 0; width: max-content; }
.grid-row { display: flex; align-items: center; height: 22px; }
.lane-name {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 82px;
  flex: none;
  font-size: 11px;
  color: var(--muted);
  padding-left: 10px;
  background: linear-gradient(90deg, #0f1812 80%, transparent);
}
.lane {
  position: relative;
  height: 100%;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: var(--bar) 100%, calc(var(--bar) / 4) 100%;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.hit {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
}
.hit.tech { box-shadow: 0 0 6px currentColor; }
.chord-row { height: 26px; margin-bottom: 4px; }
.chord {
  position: absolute;
  top: 2px;
  height: 22px;
  margin-left: 1px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  overflow: hidden;
  white-space: nowrap;
}
.chord.outside { border-color: #ff7eb0; color: #ff9ec4; background: rgba(255, 126, 176, 0.12); }
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: 82px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  pointer-events: none;
  z-index: 1;
}

/* 技法 */
.applied { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.applied-item { border-left: 3px solid var(--c); padding: 2px 0 2px 12px; }
.applied-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.applied .empty { color: var(--muted); font-size: 13px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--c, var(--border-strong));
}
.chip.on { background: color-mix(in srgb, var(--c) 22%, transparent); color: #fff; }
.chip-x { border: 0; background: transparent; color: var(--muted); padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chip-x:hover { color: #fff; }
.effect { font-size: 11px; color: var(--muted); }
.effect::before { content: "#"; }
.why { margin: 4px 0 0; font-size: 14px; }
.reason { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.candidates-wrap { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.candidates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip.cand { background: transparent; color: var(--muted); font-weight: 600; border-color: var(--border-strong); }
.chip.cand.fit { color: var(--text); border-color: var(--c); }
.chip.cand:hover { background: color-mix(in srgb, var(--c) 18%, transparent); color: #fff; }

.warnings { margin: 8px 0 0; padding-left: 18px; color: var(--accent-2); font-size: 12px; }
.warnings:empty { display: none; }

/* 基本ビート */
.beats-tab { max-width: 1100px; margin: 0 auto; padding: 16px 24px 48px; display: flex; flex-direction: column; gap: 14px; }
.beats-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.beats-filter .field { margin: 0; }
.beat-card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.beat-card .desc { margin: 0 0 10px; }
.beat-card .tips { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
@media (max-width: 900px) { .beats-tab { padding: 12px 16px 40px; } }

/* 常に手前（デスクトップ版のみ） */
.window-toggle {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 14px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.window-toggle[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
