/* お気に入りコード帳(favorites.js・favorites-page.js)の見た目。コード帳のページ・トップ(index.html)と /favorites/ で読む。
   色はサイトの変数(--ink・--surface・--brass など。ダークモードでは pages.css・index.html が入れかえる)だけを使う。
   クラス名に "ad" を含めない(広告よけの拡張機能に消されないように) */
/* いま3Dに出ているカード(黒地に白い文字)の、ダイアグラムの点の色: クリーム色(ダークモードではカードが明るくなるので、濃い色) */
:root { --fav-dot-on: var(--brass-soft); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fav-dot-on: var(--surface); } }
:root[data-theme="dark"] { --fav-dot-on: var(--surface); }

/* ---- ☆ お気に入りのボタン(3Dのコード名のすぐ右) ---- */
.name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.fav-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .84rem; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer; pointer-events: auto; }
.fav-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.fav-btn:hover { border-color: var(--muted); }
/* 入っているとき: 茶色(--brass。ダークモードでは明るい茶色)・塗った星 */
.fav-btn[aria-pressed="true"] { background: var(--brass); border-color: var(--brass); color: var(--surface); }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }
@media (max-width: 767px) { .fav-btn { font-size: .78rem; padding: 0 12px 0 10px; } }
/* 一度でもお気に入りに入れたことがある人: ☆ のアイコンだけの丸いボタン(44×44px)。文字は見えなくするが、画面読み上げには aria-label で伝える */
.fav-btn.icon-only { width: 44px; height: 44px; padding: 0; justify-content: center; }
.fav-btn.icon-only span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fav-btn.icon-only svg { width: 20px; height: 20px; }

/* ---- お知らせ(画面の下に3秒ほど。スマホは下のタブの上) ---- */
.fav-toast { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  z-index: 120; display: flex; align-items: center; gap: 10px; max-width: 520px; margin: 0 auto; padding: 8px 8px 8px 16px; border-radius: 14px;
  background: var(--ink); color: var(--surface); box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 30%, transparent); }
.fav-toast[hidden] { display: none; }
.fav-toast.is-on { animation: fav-up .2s ease-out; }
@keyframes fav-up { from { transform: translateY(12px); opacity: 0; } }
.fav-toast-text { flex: 1; min-width: 0; margin: 0; display: grid; gap: 2px; font-size: .86rem; line-height: 1.45; }
.fav-toast-text span { font-size: .78rem; opacity: .8; }
.fav-toast-text small { font-size: .74rem; opacity: .8; }
.fav-toast-act { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent;
  color: var(--brass-soft); font: inherit; font-size: .88rem; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.fav-toast-act:hover { background: color-mix(in srgb, var(--surface) 12%, transparent); }
.fav-toast.is-error { background: var(--mute); color: var(--surface); }
@media (min-width: 768px) { .fav-toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { .fav-toast.is-on { animation: none; } }

/* (ヘッダーの ☆ と数の丸は、全ページで読む site-chrome.css) */

/* ---- カードの小さなコードダイアグラム ---- */
.fav-dia { display: block; width: 100%; max-width: 104px; height: auto; margin: 0 auto; overflow: visible;
  --d-line: var(--muted); --d-ink: var(--ink); --d-dot: var(--ink); }
.fav-dia .d-fret { stroke: var(--d-line); stroke-width: 1; }
.fav-dia .d-nut { stroke: var(--d-ink); stroke-width: 3.2; stroke-linecap: square; }
.fav-dia .d-str { stroke: var(--d-line); stroke-width: 1; }
.fav-dia .d-dot { fill: var(--d-dot); }
.fav-dia .d-open { fill: none; stroke: var(--d-ink); stroke-width: 1.3; }
.fav-dia .d-mute { stroke: var(--d-ink); stroke-width: 1.4; stroke-linecap: round; }
.fav-dia .d-pos { fill: var(--d-ink); font-size: 10.5px; font-weight: 700; font-family: var(--font-mono, monospace); }

/* ===== お気に入りコード帳のページ(/favorites/) ===== */
.fav-page { gap: 14px; }
/* 3Dは1列(コード進行のページの右の列はない) */
.fav-page .play-area { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage"; }
.fav-page .play-area[hidden] { display: none; }
.fav-page .stage { height: clamp(380px, 56vh, 620px); }
.fav-controls .btn { min-width: 0; }
#favPlayBtn { min-width: 9.5em; justify-content: center; }
/* シェアされた並びのお知らせと、入れかえの確認 */
.fav-shared, .fav-confirm { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 10px 12px 10px 16px;
  border: 1px solid var(--brass); border-radius: var(--radius); background: var(--brass-soft); color: var(--ink); }
.fav-shared[hidden], .fav-confirm[hidden] { display: none; }
.fav-shared p, .fav-confirm p { margin: 0; font-weight: 700; font-size: .92rem; }
.fav-confirm-btns { display: flex; gap: 8px; }
.fav-shared .btn, .fav-confirm .btn { min-height: 44px; }
/* 一覧 */
.fav-list { display: grid; gap: 12px; padding: 16px clamp(14px, 3vw, 22px) 18px; }
.fav-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; }
.fav-head h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.3rem, 1.05rem + 1.2vw, 1.85rem); line-height: 1.35; letter-spacing: .02em; }
.fav-lead { margin: 4px 0 0; font-size: .84rem; color: var(--muted); }
.fav-lead:empty { display: none; }
.fav-head .share-bar[hidden], .fav-tools[hidden] { display: none; }
.fav-tools { display: flex; justify-content: flex-end; }
.fav-tools .btn { min-height: 44px; }
.fav-tools .btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.fav-note { margin: 0; font-size: .78rem; color: var(--muted); }
/* カード(スマホ3列・パソコン4〜6列) */
.fav-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 768px) { .fav-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; } }
@media (min-width: 1024px) { .fav-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1240px) { .fav-cards { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* 「並べ替え・削除」のあいだは、← → × を押しやすいよう、スマホでは2列に */
@media (max-width: 767px) { .fav-cards.is-editing { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fav-card { position: relative; min-width: 0; display: grid; gap: 6px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.fav-main { position: relative; display: grid; justify-items: center; gap: 2px; width: 100%; min-height: 44px; padding: 26px 8px 10px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; text-align: center;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.fav-main:hover { border-color: var(--muted); }
.fav-num { position: absolute; top: 6px; left: 9px; font-family: var(--font-mono); font-size: .74rem; font-weight: 700; color: var(--muted); }
.fav-grip { position: absolute; top: 6px; right: 7px; width: 10px; height: 16px; color: var(--muted); }
.fav-grip svg { display: block; width: 10px; height: 16px; fill: currentColor; }
.fav-name { font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; line-height: 1.2; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.fav-name.long { font-size: .95rem; }
.fav-name.xlong { font-size: .8rem; }
/* いま3Dに出ているカード: 黒地に白い文字(ダイアグラムの点はクリーム色) */
.fav-card.is-now .fav-main { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.fav-card.is-now .fav-num, .fav-card.is-now .fav-grip { color: color-mix(in srgb, var(--surface) 70%, transparent); }
.fav-card.is-now .fav-dia { --d-line: color-mix(in srgb, var(--surface) 55%, transparent); --d-ink: var(--surface); --d-dot: var(--fav-dot-on); }
/* 長押しで浮かせたカード(影・少し傾ける・少し大きく)と、置く場所 */
.fav-card.is-lifted { pointer-events: none; }
.fav-card.is-lifted .fav-main { transform: rotate(-3deg) scale(1.06); box-shadow: 0 16px 34px color-mix(in srgb, var(--ink) 32%, transparent); transition: transform .12s ease-out; }
.fav-ph { list-style: none; border: 2px dashed var(--line); border-radius: 12px; }
html.fav-dragging, html.fav-dragging body { cursor: grabbing; }
/* 「並べ替え・削除」: ← → × */
.fav-edit { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.fav-cards.is-editing .fav-edit { display: grid; }
.fav-edit button { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; }
.fav-edit button:disabled { opacity: .35; cursor: default; }
.fav-edit button[data-act="del"] { color: var(--mute); }
/* 「＋ コードを足す」(点線の枠) */
.fav-add-li { list-style: none; display: grid; min-height: 120px; }
/* 中身は上下2段: 上に黒い丸の白い「＋」(ダークモードでは --ink と --surface が入れかわるので、明るい丸に暗い「＋」)、下に「コードを足す」(1行) */
.fav-add { width: 100%; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px 4px;
  border: 2px dashed var(--line); border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; }
.fav-add-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 1rem; font-weight: 700; line-height: 1; }
.fav-add-label { white-space: nowrap; }
.fav-add:hover:not(:disabled) .fav-add-icon { background: var(--brass); }
.fav-add:hover:not(:disabled) { border-color: var(--brass); color: var(--brass); }
.fav-add:disabled { opacity: .45; cursor: default; }
/* 何も入っていないとき */
.fav-empty { display: grid; gap: 10px; padding: 18px 16px; border: 2px dashed var(--line); border-radius: 12px; text-align: center; }
.fav-empty[hidden] { display: none; }
.fav-empty p { margin: 0; font-weight: 700; }
.fav-empty-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fav-empty-links a { display: inline-grid; place-items: center; min-width: 52px; min-height: 44px; padding: 0 12px; box-sizing: border-box; border-radius: 10px; background: var(--brass-soft);
  color: var(--ink); font-family: var(--font-display); font-size: 1.15rem; text-decoration: none; }
/* すべてのコードのシート(スマホは下から、パソコンは画面のまん中) */
.fav-sheet-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(8, 10, 14, .5); }
.fav-sheet-scrim[hidden], .fav-sheet[hidden] { display: none; }
html.fav-sheet-open, html.fav-sheet-open body { overflow: hidden; }
.fav-sheet { position: fixed; z-index: 91; left: 0; right: 0; bottom: 0; max-height: 86vh; max-height: 86dvh; display: grid; grid-template-rows: auto auto auto auto minmax(0, 1fr); gap: 10px;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -12px 40px rgba(0, 0, 0, .25); }
@media (min-width: 768px) {
  .fav-sheet { left: 50%; right: auto; top: 50%; bottom: auto; width: min(760px, calc(100vw - 48px)); max-height: min(80vh, 720px); transform: translate(-50%, -50%); border-radius: 16px; padding-bottom: 18px; }
}
.fav-sheet-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding-top: 10px; }
.fav-sheet-head b { grid-column: 2; text-align: center; font-size: 1rem; }
.fav-sheet-close { grid-column: 3; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg); color: var(--ink); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.fav-search { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: 1rem; }
.fav-roots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.fav-roots button { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-weight: 700; font-size: .9rem; cursor: pointer; }
.fav-roots button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.fav-sheet-sub { margin: 0; font-size: .8rem; color: var(--muted); }
.fav-sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; overflow-y: auto; overscroll-behavior: contain; align-content: start; padding-bottom: 4px; }
@media (min-width: 768px) { .fav-sheet-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.fav-chip { position: relative; display: grid; gap: 2px; justify-items: start; min-height: 56px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.fav-chip b { font-size: .95rem; overflow-wrap: anywhere; }
.fav-chip span { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }
.fav-chip:hover { border-color: var(--muted); }
/* (基本形がもう入っているコードには、右上に ★) */
.fav-chip[aria-pressed="true"] { border-color: var(--brass); }
.fav-chip[aria-pressed="true"]::after { content: "★"; position: absolute; top: 6px; right: 8px; color: var(--brass); font-size: .8rem; }
.fav-sheet-empty { grid-column: 1 / -1; margin: 12px 0; color: var(--muted); text-align: center; }
@media (max-width: 767px) {
  .fav-page .stage { height: 360px; }
  .fav-controls { gap: 6px; }
  .fav-controls .btn { padding: 0 14px; }
}
