:root {
  --bg: #f7f7f5;
  --fg: #1f2933;
  --muted: #6b7280;
  --accent: #b45309;
  --surface: #ffffff;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  /* ノッチ付き端末の横向きでも内容が隠れないようにする */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--fg);
  color: #fff;
}
.brand { font-weight: 700; color: inherit; text-decoration: none; }
#user-area { display: flex; align-items: center; gap: 8px; font-size: 14px; }

main { padding: 24px 16px; max-width: 960px; margin: 0 auto; }

.muted { color: var(--muted); }
.error { color: #b91c1c; }

.button {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.small { padding: 4px 10px; font-size: 13px; }

.button:disabled { opacity: 0.45; cursor: default; }
.button.on { background: var(--fg); border-color: var(--fg); color: #fff; }

.login { text-align: center; padding-top: 15vh; }

.button.danger { color: #b91c1c; }
.small { font-size: 13px; }
code { font-size: 12px; background: var(--border); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
input[type="text"], input[type="search"] {
  padding: 9px 12px; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.page-head h2 { margin: 0; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: #fde68a; color: #78350f; font-size: 12px; font-weight: 600; vertical-align: middle; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 4px 16px 12px; margin: 16px 0; }
.card h3 { font-size: 16px; }
.card ol { padding-left: 20px; }

/* ライブラリ */
.search { width: 100%; margin: 12px 0; }
.song-list { list-style: none; margin: 0; padding: 0; }
.song-list .sample { border-style: dashed; }
.song-list .empty { padding: 16px 4px; }
.song-list a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: inherit; text-decoration: none;
}
.song-title { font-weight: 600; }

/* 譜面ビュー: 画面の高さに収め、譜面の領域だけをスクロールさせる（見出し・再生バーは常に見える） */
body.is-viewer { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.is-viewer main { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 8px 8px 0; display: flex; flex-direction: column; }
.viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.score-head { padding: 0 8px 8px; }
.score-title { font-size: 20px; margin: 0; }
.score-artist { font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--border); }
.chip-capo { background: var(--accent); color: #fff; font-weight: 700; }
.chip-warn { background: #fde68a; }
.score-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.score-actions .badge { margin-left: 0; }
.review-notes { font-size: 13px; color: #92400e; }
.review-notes summary { cursor: pointer; }
.review-notes ul { margin: 4px 0; padding-left: 20px; }

/* 貼り付け取り込み */
.json-input { width: 100%; min-height: 40vh; font-family: ui-monospace, Consolas, monospace; font-size: 13px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.issues { padding-left: 20px; font-size: 14px; }
.issues li { margin-bottom: 6px; }
.issues .error strong { color: #b91c1c; }
.issues .warn strong { color: #b45309; }

/* 設定 */
.token-list { list-style: none; padding: 0; }
.token-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.token-list li .button { margin-left: auto; }
.issued { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 4px 12px 8px; margin: 8px 0; }
.issued pre { white-space: pre-wrap; word-break: break-all; background: var(--surface); padding: 8px; border-radius: 6px; font-size: 13px; }
.warn-text { color: #92400e; font-weight: 600; }
.score-surface { flex: 1; min-height: 0; overflow: auto; position: relative; background: var(--surface); border-radius: 8px; }

/* 再生バー: 画面下。縦持ちスマホでは折り返す */
.player-bar {
  margin: 0 -8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
.player-group { display: flex; align-items: center; gap: 6px; }
.player-bar .button.small { padding: 8px 12px; font-size: 14px; } /* 指で押しやすい大きさ */
.speed { padding: 7px 4px; font-size: 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.player-status { font-size: 13px; }

/* 横向きスマホ（高さが低い）: 見出しと再生バーを詰めて譜面の表示領域を広げる */
@media (orientation: landscape) and (max-height: 500px) {
  .topbar { padding: 4px 16px; }
  .score-title { font-size: 16px; display: inline; margin-right: 8px; }
  .score-artist { display: none; }
  .chips { display: inline-flex; margin-top: 0; }
  .player-bar { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .player-bar .button.small { padding: 5px 10px; }
}

/* alphaTab の再生カーソル・選択範囲 */
.at-cursor-bar { background: rgba(180, 83, 9, 0.08); }
.at-cursor-beat { background: rgba(180, 83, 9, 0.75); width: 3px; }
.at-selection div { background: rgba(37, 99, 235, 0.15); }