/* 音響キュー【キュー出し・ポン出しAI】 スタイル */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #18202f;
  --muted: #667085;
  --line: #dfe4ec;
  --stage: #111827;
  --stage-soft: #1f2937;
  --stage-deep: #0b1220;
  --cyan: #0891b2;
  --cyan-soft: #e6f7fb;
  --coral: #e4572e;
  --coral-soft: #fff0eb;
  --amber: #d97706;
  --amber-soft: #fff7e8;
  --green: #047857;
  --green-soft: #e9f8f2;
  --red: #dc2626;
  --red-soft: #fdecec;
  --shadow: 0 14px 34px rgba(15, 28, 63, .10);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hidden,
[hidden] {
  display: none !important;
}

/* ---- アプリバー ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245, 246, 248, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* ノッチ/ステータスバーのセーフエリアぶん下げる（PWA全画面・ネイティブアプリで有効） */
  padding-top: env(safe-area-inset-top);
}

.appbar-inner {
  max-width: 720px;
  margin: 0 auto;
  min-height: 58px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.appbar-back {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-width: 44px;
  min-height: 40px;
  font-weight: 900;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--coral));
  color: #fff;
  font-weight: 900;
  flex: none;
  box-shadow: 0 6px 14px rgba(8, 145, 178, .22);
}

.brand-title {
  font-weight: 850;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-title small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.appbar-help {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  width: 40px;
  height: 40px;
  font-weight: 900;
  flex: none;
}

/* ---- 画面共通 ---- */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 56px;
}

.screen-lead {
  margin: 4px 2px 14px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 16px;
}

.panel + .panel,
.panel + .cue-list,
.cue-list + .panel {
  margin-top: 14px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .05em;
}

.field input[type="text"],
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 12px 13px;
  min-height: 48px;
}

.field input[type="range"] {
  width: 100%;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 0;
}

.action-btn {
  border: none;
  border-radius: 10px;
  padding: 13px 16px;
  background: var(--stage);
  color: #fff;
  font-weight: 900;
  min-height: 50px;
}

.action-btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.action-btn.danger {
  background: var(--red);
}

.action-btn:disabled {
  opacity: .5;
  cursor: default;
}

/* ---- ホーム ---- */
.home-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.set-list {
  display: grid;
  gap: 12px;
}

.set-card {
  padding: 14px 16px;
}

.set-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.set-card-name {
  flex: 1;
  min-width: 0;
  font-weight: 850;
  font-size: 17px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-card-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.set-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.set-card-actions .live-btn {
  background: linear-gradient(135deg, #22d3ee, #f97316);
  border: none;
  color: #fff;
}

.set-card-sub {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.set-card-sub button {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--muted);
  padding: 9px 6px;
  font-size: 12px;
  font-weight: 850;
  min-height: 40px;
}

.set-card-sub button.danger-text {
  color: var(--red);
}

.empty-note {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---- 編集画面 ---- */
.edit-top-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
}

.edit-top-actions .live-btn {
  background: linear-gradient(135deg, #22d3ee, #f97316);
}

.save-state {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  margin-top: 8px;
}

.cue-list {
  display: grid;
  gap: 10px;
}

.cue-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cue-card.editing {
  border-color: var(--cyan);
  background: var(--cyan-soft);
}

.cue-no {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #eef2f7;
  color: var(--muted);
  font-weight: 900;
  flex: none;
}

.cue-name {
  font-weight: 850;
  line-height: 1.4;
  word-break: break-word;
}

.cue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 850;
  background: #eef2f7;
  color: var(--muted);
}

.tag.se {
  background: var(--coral-soft);
  color: #b93818;
}

.tag.loop {
  background: var(--amber-soft);
  color: #a45c00;
}

.tag.file {
  background: var(--green-soft);
  color: var(--green);
}

.tag.warn {
  background: var(--red-soft);
  color: var(--red);
}

.cue-memo-preview {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  word-break: break-word;
}

.preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 850;
  min-height: 36px;
}

.cue-actions {
  display: grid;
  grid-template-columns: repeat(2, 38px);
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  width: 38px;
  height: 38px;
  font-weight: 900;
  font-size: 15px;
}

.mini-btn:disabled {
  opacity: .35;
  cursor: default;
}

.mini-btn.danger {
  color: var(--red);
  border-color: #f3c6c6;
}

/* ---- キューフォーム ---- */
.form-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 900;
}

.cue-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.type-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  padding: 11px 6px;
  font-weight: 850;
  min-height: 50px;
}

.type-btn.active {
  border-color: var(--cyan);
  background: var(--cyan-soft);
  color: #0e7490;
  box-shadow: inset 0 0 0 1px rgba(8, 145, 178, .18);
}

.preset-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.preset-row .mini-btn {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

.file-picker {
  border: 1px dashed #b9c4d4;
  border-radius: 10px;
  background: #fbfcfe;
  padding: 12px;
}

.file-picker .file-name {
  font-size: 13px;
  font-weight: 800;
  word-break: break-all;
  margin-top: 8px;
}

.radio-row {
  display: grid;
  gap: 8px;
}

.radio-row label.choice {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}

.radio-row input {
  accent-color: var(--cyan);
  width: 18px;
  height: 18px;
}

.inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vol-row output {
  min-width: 40px;
  text-align: right;
  font-weight: 850;
  font-size: 13px;
  color: var(--muted);
}

.fade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.fade-label {
  min-width: 40px;
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
  flex: none;
}

.fade-row input[type="range"] {
  flex: 1;
  accent-color: var(--cyan);
}

.fade-row output {
  min-width: 54px;
  text-align: right;
  font-weight: 850;
  font-size: 13px;
  color: var(--muted);
}

label.choice.fade-check {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  margin: 4px 0 0;
}

label.choice.fade-check input {
  accent-color: var(--cyan);
  width: 18px;
  height: 18px;
}

/* ---- 本番画面 ---- */
.live-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  background:
    radial-gradient(560px 300px at 88% 0%, rgba(34, 211, 238, .12), transparent 60%),
    linear-gradient(180deg, var(--stage-deep) 0%, var(--stage) 60%, var(--stage-soft) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.live-inner {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.live-head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .68);
  font-size: 13px;
  font-weight: 850;
}

.live-exit {
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 850;
  min-height: 40px;
  flex: none;
}

.live-set-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-position {
  flex: none;
}

.live-cue {
  margin-top: 12px;
}

.live-kicker {
  color: #67e8f9;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .09em;
}

.live-title {
  margin: 4px 0 0;
  min-height: 24px;
  font-size: clamp(24px, 6vw, 40px);
  line-height: 1.25;
  word-break: break-word;
}

.live-note {
  margin-top: 4px;
  min-height: 10px;
  color: rgba(255, 255, 255, .72);
  font-size: 14px;
  word-break: break-word;
}

.live-flags {
  margin-top: 4px;
  font-size: 12px;
  color: #fbbf24;
  min-height: 0;
}

.live-flags:empty {
  margin-top: 0;
}

.progress {
  margin-top: 12px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  flex: none;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #f97316);
  transition: width .25s ease;
}

.go-button {
  width: 100%;
  min-height: min(28vh, 225px);
  margin-top: 14px;
  border: none;
  border-radius: 22px;
  background: linear-gradient(135deg, #22d3ee, #f97316);
  color: #fff;
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 950;
  letter-spacing: .02em;
  box-shadow: 0 18px 40px rgba(249, 115, 22, .28);
  user-select: none;
  -webkit-user-select: none;
  transition: transform .06s ease, filter .06s ease;
}

.go-button:active {
  transform: scale(.98);
  filter: brightness(.93);
}

.go-button.looping {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.go-button.finished {
  background: linear-gradient(135deg, #334155, #475569);
  box-shadow: none;
}

.go-button:disabled {
  opacity: .55;
}

.live-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
  flex: none;
}

.live-controls button {
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  min-height: 48px;
  font-weight: 900;
  font-size: 13px;
}

.live-foot {
  margin-top: 14px;
  color: rgba(255, 255, 255, .62);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.live-foot .master-vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 170px;
}

.live-foot input[type="range"] {
  flex: 1;
  accent-color: #22d3ee;
}

.wake-state {
  color: rgba(255, 255, 255, .5);
}

.log-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding-bottom: 6px;
}

.log-line {
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 7px 10px;
  color: rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .05);
  font-size: 12px;
}

/* ---- 即出しパッド（編集画面） ---- */
.pad-banks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.pad-bank {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  padding: 9px 4px;
  font-size: 12px;
  font-weight: 850;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.pad-bank.active {
  border-color: var(--cyan);
  background: var(--cyan-soft);
  color: #0e7490;
}

.pad-bank-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--cyan);
  color: #fff;
  font-size: 11px;
}

.pad-slot-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.pad-slot-row:first-child {
  border-top: none;
  padding-top: 2px;
}

.pad-slot-no {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef2f7;
  color: var(--muted);
  font-weight: 900;
  font-size: 13px;
}

.pad-slot-fields {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.pad-slot-fields .pad-label {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 44px;
}

.pad-sound-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.pad-sound-row .pad-sound {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 44px;
}

.pad-sound-row .mini-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex: none;
}

.pad-vol-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pad-vol-label {
  font-size: 11px;
  font-weight: 850;
  color: var(--muted);
  flex: none;
}

.pad-vol-row .pad-vol {
  flex: 1;
  accent-color: var(--cyan);
}

.pad-vol-out {
  min-width: 30px;
  text-align: right;
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
}

/* ---- 即出しパッド（本番画面） ---- */
.live-pads {
  margin-top: 14px;
  flex: none;
}

.live-pads-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.live-pads-title {
  color: rgba(255, 255, 255, .68);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  flex: none;
}

.live-pads .pad-banks {
  grid-template-columns: repeat(4, 38px);
  gap: 6px;
  margin-bottom: 0;
  margin-left: auto;
}

.live-pads .pad-bank {
  min-height: 34px;
  padding: 6px 0;
  border-color: rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .85);
}

.live-pads .pad-bank.active {
  border-color: #67e8f9;
  background: rgba(103, 232, 249, .18);
  color: #a5f3fc;
}

.pad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pad-btn {
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 14px;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  min-height: 84px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 900;
  text-align: center;
}

.pad-btn .pad-btn-label {
  font-size: 15px;
  line-height: 1.25;
  word-break: break-word;
}

.pad-btn .pad-btn-kind {
  font-size: 10px;
  font-weight: 850;
  color: rgba(255, 255, 255, .6);
}

.pad-btn.empty {
  border-style: dashed;
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .32);
  font-weight: 800;
}

.pad-btn.playing {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, .22);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .4);
}

.pad-btn:active {
  transform: scale(.95);
  filter: brightness(1.12);
}

/* ---- 押した感（タップ時のフィードバック） ---- */
.action-btn,
.mini-btn,
.type-btn,
.pad-bank,
.preview-chip,
.live-controls button,
.live-exit,
.set-card-sub button {
  transition: transform .06s ease, background-color .06s ease, filter .06s ease;
}

.action-btn:active,
.mini-btn:active,
.type-btn:active,
.pad-bank:active,
.preview-chip:active,
.set-card-sub button:active {
  transform: scale(.96);
  filter: brightness(.96);
}

.live-controls button:active,
.live-exit:active {
  transform: scale(.95);
  background: rgba(255, 255, 255, .2);
}

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, .35);
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.modal-body {
  color: var(--ink);
  font-size: 14px;
}

.modal-body p {
  margin: 0 0 10px;
}

.modal-body .hint {
  margin-top: 2px;
}

.modal-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions.two-cols {
  grid-template-columns: 1fr 1fr;
}

.qr-wrap {
  display: grid;
  place-items: center;
  padding: 10px 0;
}

.qr-wrap canvas {
  width: min(78vw, 300px);
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.help-steps {
  margin: 0;
  padding-left: 20px;
}

.help-steps li {
  margin-bottom: 8px;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }
}

/* ---- トースト ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  transform: translateX(-50%) translateY(90px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: var(--stage);
  color: #fff;
  padding: 12px 18px;
  font-weight: 850;
  font-size: 14px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 12px 28px rgba(17, 24, 39, .28);
  transition: transform .22s ease, opacity .22s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

footer.app-foot {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px 40px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}
