:root {
  --bg: #f2f2f7;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --accent: #0d9488;
  --border: #e5e5ea;
  --danger: #ff3b30;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --panel: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #2dd4bf;
    --border: #2c2c2e;
  }
}

* { box-sizing: border-box; }
/* display指定を持つ要素（.image-wrap等）でもhidden属性を必ず効かせる */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
section[hidden] { display: none; }

header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.bar-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.icon {
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
button.icon svg { width: 100%; height: 100%; display: block; }
button.icon:active { background: var(--border); }
/* 長押しでiOSの選択メニュー/コールアウトが出ないように（リンクボタンの長押しを使うため）。
   touch-action:none で、押している間にOSがスクロール/ズーム判定へ横取りして
   pointercancel を出す（＝長押しが発火しない）のを防ぐ。 */
#insertLinkBtn { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: none; }

/* パン屑リスト（現在地の経路） */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 12px 8px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb:empty { display: none; }
.breadcrumb .crumb {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  padding: 3px 5px;
  border-radius: 7px;
  cursor: pointer;
  flex-shrink: 0;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb button.crumb:active { background: var(--border); }
.breadcrumb .crumb.current {
  color: var(--muted);
  font-weight: 600;
  cursor: default;
}
.breadcrumb .crumb-sep {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

button.primary {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 28px;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.5; }

/* ---------- ログイン画面 ---------- */

#authView { justify-content: center; }
.auth-box {
  text-align: center;
  padding: 24px;
  max-width: 420px;
  margin: 0 auto;
}
.auth-logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
}
.auth-box h1 { margin: 12px 0 8px; }
.auth-box p { color: var(--text); line-height: 1.7; }
.auth-box p.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 24px;
}
.error { color: var(--danger); font-size: 14px; }

/* ---------- 一覧 ---------- */

#entryList {
  list-style: none;
  margin: 4px 12px;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateZ(0);
  border-radius: 12px;
}
#entryList li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#entryList li:first-child { border-radius: 12px 12px 0 0; }
#entryList li:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
#entryList li:only-child { border-radius: 12px; }
#entryList li:active { background: var(--border); }
.entry-icon {
  width: 24px;
  height: 24px;
  color: var(--muted);
  flex-shrink: 0;
}
.entry-icon.folder { color: var(--accent); }
.entry-icon svg { width: 100%; height: 100%; display: block; }
.entry-main {           /* 名前（上）と抜粋（下）を縦に積む。横幅は行の残り全部 */
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.file-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-date {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
  align-self: flex-start;
}
/* MOCノート風の一覧行：中身を主役に、名前と日付は下に小さく（アイコンなし） */
.entry-excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.entry-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.entry-fname {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-date {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}
.empty {
  text-align: center;
  color: var(--muted);
  margin-top: 48px;
  line-height: 1.8;
}

/* ---------- リーダー・エディタ ---------- */

.statusbar {
  padding: 0 18px 6px;
  min-height: 22px;
}
#saveStatus { color: var(--muted); font-size: 12px; }
#saveStatus.error { color: var(--danger); }

#editor {
  flex: 1;
  min-height: 0;
  border: 0;
  resize: none;
  outline: none;
  margin: 0 12px;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 16px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: 16px/1.8 ui-monospace, "SF Mono", Menlo, monospace;
}

.preview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* iOS Safariでスクロール領域の後半が描画されないことがある対策 */
  -webkit-overflow-scrolling: touch;
  transform: translateZ(0);
  margin: 0 12px;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--panel);
  line-height: 1.8;
  word-break: break-word;
}
.preview h1, .preview h2, .preview h3 { line-height: 1.4; }
.preview h1 { font-size: 24px; }
.preview h2 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.preview h3 { font-size: 17px; }
.preview code {
  background: var(--bg);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.preview pre {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
}
.preview pre code { background: transparent; padding: 0; }
.preview pre.plain {
  background: transparent;
  padding: 0;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 15px/1.8 ui-monospace, "SF Mono", Menlo, monospace;
}
.preview blockquote {
  margin: 8px 0;
  padding: 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.preview a { color: var(--accent); }
.preview a.wikilink {
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.preview hr { border: 0; border-top: 1px solid var(--border); }
/* [[リンク]]の下に出す、リンク先の冒頭抜粋（開かずに中身が分かる） */
.wikilink-preview {
  display: block;
  margin: 1px 0 6px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wikilink-preview.empty { font-style: italic; opacity: 0.7; }
.frontmatter {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
}
.frontmatter summary { cursor: pointer; }
.frontmatter pre {
  margin: 8px 0 2px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.image-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 12px;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
  border-radius: 12px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ---------- つながりマップ ---------- */

.graph-wrap {
  flex: 1;
  min-height: 0;
  margin: 0 12px;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* ピンチ・ドラッグを画面スクロールに取られない */
}

/* ---------- バックリンク ---------- */

.backlinks {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.backlinks h4 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
}
.backlink {
  padding: 8px 0;
}
.backlink + .backlink {
  border-top: 1px solid var(--border);
}
.backlink-text {                 /* リンク元の全文。既定は2行で切り、タップでその場展開 */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: pre-wrap;         /* 全文表示のとき改行を保つ */
  color: var(--text);
  font-size: 12px;               /* 日付と同じ大きさ。件数が増えてもスクロールを抑える */
  line-height: 1.45;
}
.backlink-text.truncatable { cursor: pointer; }
.backlink-text.truncatable.expanded {
  -webkit-line-clamp: unset;
  overflow: visible;
}
.backlink-meta {                 /* 「続きを読む」（左）と 日付↗（右）を1行に置く */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}
.backlink-toggle {
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
.backlink-name {
  color: var(--muted);
  font-size: 12px;
}
.backlink-name.link {            /* 日付タップ＝編集画面へ */
  color: var(--accent);
  cursor: pointer;
}
.backlink-name.solo { margin-left: auto; text-align: right; }

/* ---------- タブバー ---------- */

#tabBar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}
#tabBar button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  padding: 6px 0 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
#tabBar button svg { width: 24px; height: 24px; }
#tabBar button.active { color: var(--accent); }

/* ---------- お気に入り・最近（一覧の差し込み） ---------- */

#entryList li.list-head {
  background: transparent;
  border-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 12px 4px 4px;
  cursor: default;
  border-radius: 0;
}

/* ---------- 星ボタン ---------- */

#starBtn.on svg path { fill: currentColor; }

/* ---------- チェックボックス ---------- */

.preview li.task { list-style: none; margin-left: -20px; }
.preview li.task label { display: flex; gap: 9px; align-items: flex-start; }
.preview li.task input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin: 5px 0 0;
  accent-color: var(--accent);
}
.preview li.task input:checked + span {
  color: var(--muted);
  text-decoration: line-through;
}

/* ---------- 検索 ---------- */

.search-box { padding: 0 12px 8px; }
.search-box input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
  -webkit-appearance: none;
}
.scope-row {
  display: flex;
  gap: 8px;
  padding: 0 12px 8px;
}
button.chip {
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  padding: 5px 14px;
  cursor: pointer;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#searchResults {
  list-style: none;
  margin: 4px 12px;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}
#searchResults li {
  background: var(--panel);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#searchResults li:first-child { border-radius: 12px 12px 0 0; }
#searchResults li:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
#searchResults li:only-child { border-radius: 12px; }
#searchResults li:active { background: var(--border); }
.result-name { display: block; font-size: 15px; font-weight: 600; }
.result-snippet {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- カレンダー ---------- */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin: 0 12px 8px;
  flex-shrink: 0;
}
.cal-w {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 0;
}
.cal-d {
  background: var(--panel);
  border-radius: 8px;
  min-height: 46px;
  padding: 4px 0 3px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cal-d.today span { color: var(--accent); font-weight: 700; }
.cal-d.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-n {
  font-style: normal;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  font-size: 10px;
  line-height: 15px;
  min-width: 16px;
  padding: 0 3px;
}
#calList {
  list-style: none;
  margin: 4px 12px;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  flex: 1;
  min-height: 0;
}
#calList li {
  display: flex;
  align-items: center;
  background: var(--panel);
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#calList li:first-child { border-radius: 12px 12px 0 0; }
#calList li:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
#calList li:only-child { border-radius: 12px; }
#calList li:active { background: var(--border); }

/* ---------- タグ選択シート ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 72dvh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.sheet-head {
  display: flex;
  align-items: center;
}
.sheet-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}
.sheet-input {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}
.sheet-input input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
}
button.mini {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 0 14px;
  cursor: pointer;
  flex-shrink: 0;
}
#tagList {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}
#tagList li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#tagList li:first-child { border-radius: 12px 12px 0 0; }
#tagList li:last-child { border-radius: 0 0 12px 12px; border-bottom: 0; }
#tagList li:only-child { border-radius: 12px; }
#tagList li:active { background: var(--border); }
#tagList li.tag-asis {           /* 「そのまま [[語]]」の行を少し目立たせる */
  background: var(--accent-weak, rgba(13,148,136,0.12));
  font-weight: 600;
}
#tagList li.tag-asis .file-name { color: var(--accent); }
.sheet .empty { margin: 24px 0; }

/* 新規作成・削除確認のボタン列 */
.new-actions {
  display: flex;
  gap: 10px;
  margin: 4px 0 2px;
}
.new-actions button { flex: 1; }
button.ghost {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  cursor: pointer;
}
button.ghost:active { background: var(--border); }
button.danger {
  border: 0;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  cursor: pointer;
}
button.danger:active { opacity: 0.85; }
.confirm-msg {
  margin: 12px 2px 16px;
  line-height: 1.7;
  color: var(--text);
  font-size: 15px;
}

/* 管理モード：ヘッダーのゴミ箱を強調＋各行の削除ボタン */
button.icon.active { background: var(--danger); color: #fff; }
.row-del {
  width: 34px;
  height: 34px;
  padding: 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}
.row-del svg { width: 100%; height: 100%; display: block; }
.row-del:active { background: var(--border); }

/* ---------- トースト ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 22px;
  max-width: 86vw;
  z-index: 10;
}

/* 行リンクで飛んだ着地点を一瞬ハイライトする */
@keyframes linkFlash {
  from { background: rgba(13, 148, 136, 0.28); }
  to { background: transparent; }
}
.link-flash {
  animation: linkFlash 1.6s ease-out;
  border-radius: 6px;
}

/* 行リンク作成モード：本文の各行を選べるように見せる */
#readerContent.picking [data-line] {
  cursor: pointer;
  outline: 1px dashed rgba(13, 148, 136, 0.45);
  outline-offset: 3px;
  border-radius: 4px;
}
#readerContent.picking [data-line]:active {
  background: rgba(13, 148, 136, 0.16);
}

/* ---------- 音楽タブ ---------- */
.music-controls { padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
#musicSearch {
  width: 100%; font-size: 16px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text);
}
.music-chips { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.music-chips .chip { flex-shrink: 0; white-space: nowrap; }
#musicSort {
  align-self: flex-start; font-size: 14px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text);
}
.music-count { padding: 2px 12px 6px; font-size: 12px; color: var(--muted); margin: 0; }
#musicList { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
/* 音楽ビュー内のアーティスト/アルバム/曲 切替 */
.music-cats { display: flex; gap: 6px; padding: 6px 12px 0; }
.music-cats button { flex: 1; font-size: 13px; padding: 8px 2px; white-space: nowrap; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); }
.music-cats button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.artist-filter { padding: 6px 12px 0; }
.artist-filter button { font-size: 13px; padding: 6px 10px; border: 1px solid var(--accent); border-radius: 14px; background: none; color: var(--accent); }
#musicList li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
#musicList li:active { background: var(--border); }
#musicList .m-main { min-width: 0; flex: 1; }
#musicList .m-t { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#musicList .m-s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#musicList .m-r { color: #e8a300; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
#musicList li.m-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; border-bottom: none; background: none; }
#musicList li.m-head:active { background: none; }
.revolve-btn { font-size: 12px; font-weight: 600; padding: 5px 12px; border: 1px solid var(--accent); border-radius: 14px; background: none; color: var(--accent); }
.revolve-btn:active { background: var(--border); }
#musicList li.m-head.hist-row { justify-content: flex-start; padding-top: 18px; border-top: 1px solid var(--border); margin-top: 6px; }
#musicList li.m-head.hist-head { font-weight: 600; color: var(--muted); opacity: .85; padding-top: 10px; }
#musicList li.m-head.hist-sec { font-size: 13px; font-weight: 700; color: var(--text); opacity: 1; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 8px; }
#musicList li.m-note { padding: 10px 12px; color: var(--muted); font-size: 13px; border-bottom: none; }
/* 今日の⭐️ */
#musicList li.m-head.star-prog { font-weight: 600; color: var(--muted); opacity: .9; padding-top: 2px; }
#musicList li.star-song .m-r { color: var(--muted); font-size: 12px; }
#musicList li.star-song.done { opacity: .45; }
#musicList li.star-song.done .m-r { color: var(--accent); }
/* 「聴いた/未聴」手動切替ボタン。指で押しやすいよう右端に置く。 */
#musicList li.star-song .m-r .star-mark {
  font: inherit; font-size: 12px; color: var(--muted);
  background: rgba(127,127,127,.12); border: 1px solid rgba(127,127,127,.25);
  border-radius: 999px; padding: 6px 12px; min-width: 56px; text-align: center;
  cursor: pointer; white-space: nowrap;
}
#musicList li.star-song .m-r .star-mark.on {
  color: var(--accent); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.track-plays { font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
.music-more {
  display: block; width: calc(100% - 24px); margin: 10px 12px; padding: 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text);
}
/* アルバム編集シート */
.album-body { padding: 6px 16px 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.album-sub { font-size: 13px; color: var(--muted); }
.album-play {
  display: inline-block; align-self: flex-start; padding: 10px 16px;
  border: 1px solid #c00; border-radius: 10px; color: #c00; text-decoration: none; font-size: 15px;
}
.album-field { display: flex; flex-direction: column; gap: 6px; }
.album-field > label { font-size: 12px; color: var(--muted); }
.album-field input, .album-field textarea {
  width: 100%; font-size: 16px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text);
}
.stars { display: flex; gap: 4px; }
.stars .star { font-size: 26px; line-height: 1; background: none; border: none; color: var(--border); padding: 0 2px; }
.stars .star.on { color: #e8a300; }
.album-save { font-size: 12px; color: var(--muted); min-height: 1em; }

/* アルバムシート内の収録曲 */
.track-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.track { border-bottom: 1px solid var(--border); }
.track:last-child { border-bottom: none; }
.track-head { display: flex; align-items: center; gap: 8px; padding: 9px 10px; }
.track-t { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-meta { font-size: 12px; color: #e8a300; white-space: nowrap; }
.track-edit { padding: 2px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.track-play { align-self: flex-start; font-size: 13px; color: #c00; text-decoration: none; }
.track-stars .star { font-size: 20px; color: var(--border); background: none; border: none; padding: 0 2px; }
.track-stars .star.on { color: #e8a300; }
.track-memo { width: 100%; font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); }
.album-note { align-self: flex-start; padding: 10px 14px; font-size: 14px; border: 1px solid var(--accent); border-radius: 10px; background: none; color: var(--accent); }

/* ===== 音楽タブ／シート: 白ベース＋グラデ差し色（音楽ノートに合わせる） ===== */
/* 切替タブ：選択中はグラデ */
#musicView .music-cats button { background: var(--panel); border: 1px solid var(--border); color: var(--muted); }
#musicView .music-cats button.on {
  background: linear-gradient(120deg,#6a3cff,#b14bff 55%,#ff5b9c); color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px rgba(150,60,220,.35);
}
/* チップ：選択中はグラデ */
#musicView .music-chips .chip.active, #albumSheet .music-chips .chip.active {
  background: linear-gradient(120deg,#6a3cff,#b14bff 55%,#ff5b9c); color: #fff; border-color: transparent;
}
#musicView #artistFilter button { border-color: #b14bff; color: #8b2cff; }
/* 一覧の行：グラデの丸タイル＋金の★ */
#musicView #musicList li::before {
  content: "♪"; width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg,#7a2cff,#ff5b9c); display: flex; align-items: center; justify-content: center;
  font-size: 19px; color: #fff; box-shadow: 0 3px 10px rgba(140,50,210,.28);
}
#musicView #musicList li[data-artist]::before { content: "◐"; }
#musicView #musicList li[data-v]::before { content: "♪"; }
#musicView #musicList .m-r { color: #e8a300; }

/* アルバムシート：白パネルのまま、タイトルをグラデ文字・再生をグラデ丸ボタンに */
#albumSheetTitle {
  background: linear-gradient(120deg,#6a3cff,#b14bff 55%,#ff5b9c);
  -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800;
}
#albumSheet .album-play, #albumSheet .track-play {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: none;
  background: linear-gradient(135deg,#7a2cff,#ff5b9c); color: transparent; font-size: 0; padding: 0;
  text-decoration: none; box-shadow: 0 4px 12px rgba(140,50,210,.35); flex-shrink: 0;
}
#albumSheet .album-play { width: 52px; height: 52px; }
#albumSheet .track-play { width: 30px; height: 30px; }
#albumSheet .album-play::before, #albumSheet .track-play::before { content: "▶"; color: #fff; margin-left: 2px; }
#albumSheet .album-play::before { font-size: 19px; }
#albumSheet .track-play::before { font-size: 12px; }
#albumSheet .album-note { border: 1px solid #b14bff; color: #8b2cff; background: none; border-radius: 999px; }
#albumSheet .stars .star.on, #albumSheet .track-stars .star.on { color: #e8a300; }

/* ===== 音楽ノート（リーダー）Cスタイル ===== */
.preview.music-note h1 {
  font-size: 27px; font-weight: 800; line-height: 1.25; margin: 4px 0 2px;
  background: linear-gradient(120deg,#6a3cff,#b14bff 55%,#ff5b9c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.preview.music-note h1 + p { color: var(--muted); }
/* 再生リンク（絵文字→丸い再生ボタン） */
.preview.music-note a[href*="music.youtube.com"] {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; vertical-align: middle;
  background: linear-gradient(135deg,#7a2cff,#ff5b9c); text-decoration: none;
  font-size: 0; box-shadow: 0 3px 10px rgba(120,40,200,.4); flex-shrink: 0;
}
.preview.music-note a[href*="music.youtube.com"]::before { content: "▶"; color: #fff; font-size: 12px; margin-left: 2px; }
.preview.music-note a[href*="music.youtube.com"]:active { transform: scale(.92); }
/* 見出し直後のアルバム再生ボタンは少し大きく */
.preview.music-note h1 + p + a[href*="music.youtube.com"],
.preview.music-note h1 + a[href*="music.youtube.com"] { width: 46px; height: 46px; box-shadow: 0 6px 18px rgba(120,40,200,.45); }
.preview.music-note h1 + p + a[href*="music.youtube.com"]::before,
.preview.music-note h1 + a[href*="music.youtube.com"]::before { font-size: 17px; }
/* 収録曲 */
.preview.music-note h2 {
  font-size: 15px; font-weight: 700; letter-spacing: .04em; color: var(--muted);
  border: none; padding: 0; margin: 26px 0 6px;
}
.preview.music-note ol { list-style: none; margin: 0; padding: 0; counter-reset: trk; }
.preview.music-note ol li {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px;
  border-bottom: 1px solid var(--border); counter-increment: trk;
}
.preview.music-note ol li::before {
  content: counter(trk); color: var(--muted); font-size: 13px; width: 20px;
  text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.preview.music-note ol li a.wikilink { flex: 1; min-width: 0; text-decoration: none; color: var(--text); font-size: 15px; }
.preview.music-note ol li a[href*="music.youtube.com"] { margin-left: auto; }
/* 見出し直後の段落内の再生ボタン＝アルバム再生を大きく（markdownでは<p>内に入るため） */
.preview.music-note h1 + p a[href*="music.youtube.com"] { width: 48px; height: 48px; box-shadow: 0 6px 18px rgba(120,40,200,.45); }
.preview.music-note h1 + p a[href*="music.youtube.com"]::before { font-size: 18px; }

/* 音楽タブ 頭文字インデックス（すべて/A/あ/0/他 → 展開） */
#musicView .music-idx { padding: 6px 12px 0; }
#musicView .music-idx .idxrow { display: flex; gap: 5px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
#musicView .music-idx .idxrow.sub { margin-top: 5px; }
#musicView .music-idx button {
  font-size: 13px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel); color: var(--muted); flex-shrink: 0; white-space: nowrap;
}
#musicView .music-idx button.on {
  background: linear-gradient(120deg,#6a3cff,#b14bff 55%,#ff5b9c); color: #fff; border-color: transparent;
}

/* アルバムシート：ジャンルのタグ入力 */
#albumSheet .genre-tags, #albumSheet .genre-sug { display: flex; flex-wrap: wrap; gap: 6px; }
#albumSheet .genre-sug { margin-top: 6px; max-height: 128px; overflow-y: auto; }
#albumSheet .genre-empty { color: rgba(255,255,255,.6); font-size: 13px; }
#albumSheet .genre-tags .chip { background: linear-gradient(120deg,#6a3cff,#b14bff 55%,#ff5b9c); color: #fff; border: none; }
#albumSheet .genre-sug .chip.new { border-color: #ff8ecb; color: #ffd0e8; font-weight: 600; }

/* 並べ替え＋ジャンルの2つのドロップダウン */
#musicView .music-selects { display: flex; gap: 8px; }
#musicView .music-selects select { flex: 1; min-width: 0; }
#musicView #musicGenre {
  font-size: 14px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text);
}
#musicView #musicGenre option { color: #111; }
