/* ==========================================
   モダン・ダーク・ジャズ スタイル
   元のカラー・ブランドデザインを100死守
   ========================================== */
:root {
    --bg-deep: #121417;      /* 背景：深い夜 */
    --card-bg: #1e2227;      /* パネル背景 */
    --brass: #d4af37;        /* 基本色：真鍮ゴールド */
    --text-main: #f0f0f0;
    
    /* ボタンの区別用カラー */
    --btn-symbol: #4a5568;   /* 記号挿入：落ち着いたグレーブルー */
    --btn-check: #a93226;    /* 拍数チェック：警告の赤 */
    --btn-save: #27ae60;     /* 保存：成功の緑 */
    --btn-sample: #2c3e50;   /* サンプル：深い紺 */
    --btn-save-midi: #0256f1;     /* 保存：成功の緑 */
}

* { box-sizing: border-box; }

body {
    background: var(--bg-deep); /* 漆黒の背景を維持 */
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding: 8px; /* スマホ用に縦幅を稼ぐ調整 */
    margin: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
}

h3 {
    color: var(--brass);
    margin: 2px 0 8px 0;
}

/* --- ヘルプエリア --- */
details {
    background: var(--card-bg);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    margin-bottom: 8px;
}
summary{
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--brass);
    font-weight: bold;
    cursor: pointer;
}

.near-summary {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--brass);
    font-weight: bold;
}

.sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    padding: 10px;
}

.sample-grid button {
    background: var(--btn-sample) !important;
    border: 1px solid var(--brass) !important;
    color: var(--brass) !important;
    font-size: 0.75rem;
}

/* --- メインツールバー --- */
.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

button {
    flex: 1 1 calc(25% - 8px);
    padding: 14px 5px;
    background: var(--btn-symbol);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

button:active { transform: scale(0.96); }

.btn-check {
    background: var(--btn-check) !important;
    border: none !important;
}

/* --- 入力エリア --- */
textarea {
    width: 100%;
    height: 100px;
    background: #000;
    color: #00ff41; /* エディタらしい緑 */
    border: 1px solid var(--brass);
    border-radius: 8px;
    padding: 15px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 16px;
    margin-bottom: 15px;
    outline: none;
}

/* 楽譜プレビューを画面上部に固定 */
#paper {
    background: #ffffff !important;
    border-radius: 8px;
    padding: 20px;
    overflow-x: auto;
    min-height: 120px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    
    /* 以下を追加 */
    position: sticky;
    top: 0;
    z-index: 100;
}

#paper svg path, 
#paper svg text,
#paper svg rect {
    fill: #000000 !important;
    stroke: #000000 !important;
}

/* テキスト入力欄もそのすぐ下に固定 */
#abc-input {
    width: 100%;
    height: 80px; /* 少し高さを抑える */
    background: #000;
    color: #00ff41;
    border: 1px solid var(--brass);
    border-radius: 8px;
    padding: 10px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 16px;
    margin-bottom: 10px;
    outline: none;
    
    /* 以下を追加 */
    position: sticky;
    top: 160px; /* paperの高さに応じて調整 */
    z-index: 99;
}

/* --- 画像保存ボタン --- */
button[onclick="saveAsImage()"] {
    width: 100%;
    max-width: 900px;
    background: var(--btn-save) !important;
    border: none;
    color: white;
    padding: 12px;
    font-size: 1.1rem;
    margin: 10px auto;
    display: block;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
    flex: none;
    margin-top: 8px;
}

button[onclick="saveAsImage()"]:hover {
    filter: brightness(1.1);
}

/* --- 画像保存ボタン --- */
button[onclick="saveAsMidi()"] {
    width: 100%;
    max-width: 900px;
    background: var(--btn-save-midi) !important;
    border: none;
    color: white;
    padding: 12px;
    font-size: 1.1rem;
    margin: 10px auto;
    display: block;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
    flex: none;
    margin-top: 8px;
}

button[onclick="saveAsMidi()"]:hover {
    filter: brightness(1.1);
}

/* --- 音符セレクターのスタイル --- */
.note-selector {
    background: var(--card-bg);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--brass);
}

.duration-picker {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 5px;
}

.note-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.note-grid button {
    height: 44px;
    background: var(--brass);
    color: var(--bg-deep);
    font-size: 1.1rem;
    flex: none;
    width: 100%;
}

.nuance-grid button,
.jazz-mode-grid button {
    height: 34px;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
}

button[onclick*="Swing"] {
    font-weight: 800;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

/* ==========================================
   ★ 追加されたスマホ・チュートリアル用CSS ★
   （元のデザインに影響を与えない独立コード）
   ========================================== */

/* 追加：新セクションガイドの見出しスタイル */
.section-guide {
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    color: var(--brass); /* 元の真鍮ゴールドをそのまま使用して超見やすく！ */
    border-left: 3px solid var(--brass); /* 左側にゴールドの縦線を入れてゾーニング */
    padding-left: 6px;
    margin: 14px 0 6px 2px;
    display: block;
}

/* チュートリアルポップアップ背景 */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85); /* 背後をしっかりシールド */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ポップアップカード（ダークテーマ仕様） */
.tutorial-card {
    background: #1a1a1a;
    border: 2px solid var(--brass); /* 枠線も真鍮ゴールドで統一 */
    border-radius: 12px;
    padding: 24px;
    max-width: 340px;
    width: 85%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.tutorial-card h4 {
    color: var(--brass);
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}

.tutorial-subtitle {
    color: #ccc;
    font-size: 0.75rem;
    margin-bottom: 20px;
}

.tutorial-steps {
    text-align: left;
    margin-bottom: 24px;
}

.step-item {
    color: #fff;
    font-size: 0.85rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

/* ステップの丸数字アイコン */
.step-item span {
    background: var(--brass); /* 丸数字の背景も真鍮ゴールド */
    color: var(--bg-deep);     /* 文字色は深い夜 */
    font-weight: bold;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* チュートリアルを閉じるボタン */
.btn-tutorial-close {
    background: var(--btn-save); /* 既存の「保存」と同じ緑で統一 */
    color: white;
    border: none;
    padding: 12px 0;
    width: 100%;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn-tutorial-close:active {
    transform: scale(0.98);
}

/* ==========================================
   スマートフォン向けのレイアウト微調整（追記）
   ========================================== */
@media (max-width: 480px) {
    /* ③ ジャズのニュアンスボタン：スマホでは2列×2行にして文字を確実に収める */
    .section-guide:nth-of-type(5) + .note-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    /* ④ 楽譜の編集ボタン：2つしかないので、綺麗に 1:1 で並ぶように修正 */
    .section-guide:nth-of-type(6) + .note-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    /* スマホの時だけボタンの文字サイズと余白を最適化して見切れを防ぐ */
    .note-grid button {
        font-size: 0.9rem !important; /* 少しだけ小さくして1行に収める */
        padding: 10px 2px !important;  /* 縦のパディングを少し削ってコンパクトに */
        height: auto !important;       /* 高さをコンテンツに合わせる */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;           /* ボタン内での意図しない自動改行を禁止 */
    }
}
/* --- アコーディオンメニューのスタイル --- */
.accordion-menu {
    display: none; /* 初期状態は非表示 */
    background: #1a1a1a; 
    padding: 10px; 
    border-radius: 8px; 
    margin-top: 5px; 
    border: 1px solid var(--brass);
}