/* =============================================
   LuminaLive Shell - SPA 共通スタイル
   ============================================= */

/* SVG アイコン共通 (icons.js で生成された <svg class="ll-icon">) */
.ll-icon {
    display: inline-block;
    vertical-align: -2px;
    flex-shrink: 0;
}
.ll-icon + span,
button .ll-icon,
a .ll-icon {
    margin-right: 2px;
}

/* ============ テーマ変数 ============ */
/* color-scheme でブラウザ標準 UI (date picker / scrollbar 等) もテーマ追従 */
[data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
[data-theme="system"] { color-scheme: light dark; }

/* デフォルト = ダーク */
:root, [data-theme="dark"] {
    --bg: #0b0d12;
    --surface: #111419;
    --surface2: #171b21;
    --surface3: #1b1f27;
    --border: #272c36;
    --accent: #ff893b;
    --accent-dim: #c46a30;
    --accent-fg: #1a1207;        /* アクセント背景上の文字色 (ダーク=黒) */
    --text: #ebeff4;
    --text-dim: #9a9fa6;
    --text-muted: #6b7180;
    --danger: #ef4444;
    --success: #10b981;
    --warn: #f59e0b;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-modal: 0 12px 40px rgba(0,0,0,0.6);
    --shell-header-h: 48px;
    /* タイムライン Canvas 用 (sequencer の timeline.js が getComputedStyle で読む) */
    --tl-bg: #07090e;
    --tl-bg-alt: #13161c;
    --tl-line-measure: #2a2d35;
    --tl-line-beat: #1f2228;
    --tl-line-subdiv: #15181e;
    --tl-text: #6d7279;
    --tl-overlay-strong: rgba(255,255,255,0.6);
    --tl-overlay-mid: rgba(255,255,255,0.4);
    --tl-overlay-weak: rgba(255,255,255,0.2);
    --tl-shadow: rgba(0,0,0,0.3);
    --tl-shadow-strong: rgba(0,0,0,0.75);
}

/* ライトモード */
[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f6f7f9;
    --surface2: #eef0f3;
    --surface3: #e3e6ec;
    --border: #d8dce3;
    --accent: #ea7426;
    --accent-dim: #c66220;
    --accent-fg: #ffffff;        /* ライトモードはアクセント背景上の文字を白に */
    --text: #14181f;
    --text-dim: #4a525c;
    --text-muted: #7a818c;
    --danger: #dc2626;
    --success: #059669;
    --warn: #d97706;
    --shadow-card: 0 1px 3px rgba(20,24,31,0.08);
    --shadow-modal: 0 12px 40px rgba(20,24,31,0.18);
    /* ライト用タイムライン色 */
    --tl-bg: #f5f7fa;
    --tl-bg-alt: #e9ecf0;
    --tl-line-measure: #b8bdc6;
    --tl-line-beat: #d2d6dd;
    --tl-line-subdiv: #e3e6ec;
    --tl-text: #6d7279;
    --tl-overlay-strong: rgba(0,0,0,0.55);
    --tl-overlay-mid: rgba(0,0,0,0.35);
    --tl-overlay-weak: rgba(0,0,0,0.18);
    --tl-shadow: rgba(20,24,31,0.10);
    --tl-shadow-strong: rgba(20,24,31,0.4);
}

/* システム設定追従 (data-theme="system" 時) */
@media (prefers-color-scheme: light) {
    [data-theme="system"] {
        --bg: #ffffff;
        --surface: #f6f7f9;
        --surface2: #eef0f3;
        --surface3: #e3e6ec;
        --border: #d8dce3;
        --accent: #ea7426;
        --accent-dim: #c66220;
        --accent-fg: #ffffff;
        --text: #14181f;
        --text-dim: #4a525c;
        --text-muted: #7a818c;
        --danger: #dc2626;
        --success: #059669;
        --warn: #d97706;
        --shadow-card: 0 1px 3px rgba(20,24,31,0.08);
        --shadow-modal: 0 12px 40px rgba(20,24,31,0.18);
    }
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
}

/* ===== Shell ヘッダー (3カラム構成: left / center / right) ===== */
.shell-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--shell-header-h);
    background: linear-gradient(to bottom, var(--surface2), var(--surface));
    border-bottom: 1px solid var(--border);
    display: grid;
    /* 左右 1fr で対称化 → 中央カラムが必ずページ中央に来る (検索バーのズレ防止)
       中央カラムは検索バー max-width(560) + 余白を許容する 720px 上限 */
    grid-template-columns: 1fr minmax(0, 720px) 1fr;
    align-items: center;
    gap: 24px;
    padding: 0 16px;
}
.shell-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}
.shell-header-center {
    display: flex;
    justify-content: center;
    min-width: 0;
}
.shell-header-right {
    display: flex;
    align-items: center;
    /* 右側コンテンツは右端寄せ (1fr カラムの右端) */
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}
.shell-brand {
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.shell-brand-logo {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
}
/* ===== ロゴ: レインボーネオン ===== */
.shell-logo {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.02em;
    /* 赤→橙→黄→緑→青→紫→ピンク→赤 (ペンライトのレインボーと統一) */
    background: linear-gradient(
        90deg,
        #ff3b3b 0%,
        #ff8c1a 14%,
        #ffe33d 28%,
        #52ff5a 43%,
        #3ec8ff 57%,
        #8a55ff 72%,
        #ff4dc0 86%,
        #ff3b3b 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    /* ネオン発光 (透明テキストには text-shadow が効かないので filter で代用) */
    filter:
        drop-shadow(0 0 4px rgba(255, 80, 200, 0.55))
        drop-shadow(0 0 10px rgba(120, 200, 255, 0.35))
        drop-shadow(0 0 18px rgba(255, 200, 120, 0.18));
    /* 緩やかにレインボーが流れる */
    animation: lumina-rainbow-shift 12s linear infinite;
    transition: filter 0.2s;
}
.shell-brand:hover .shell-logo {
    /* ホバー時に発光強化 */
    filter:
        drop-shadow(0 0 6px rgba(255, 80, 200, 0.85))
        drop-shadow(0 0 14px rgba(120, 200, 255, 0.55))
        drop-shadow(0 0 22px rgba(255, 200, 120, 0.30));
}
@keyframes lumina-rainbow-shift {
    0%   { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}
/* アクセシビリティ: 動きを抑制したいユーザー向け */
@media (prefers-reduced-motion: reduce) {
    .shell-logo { animation: none; }
}
.shell-nav {
    display: flex;
    gap: 4px;
}
.shell-nav-link {
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.shell-nav-link:hover {
    background: var(--surface3);
    color: var(--text);
}
.shell-nav-link.active {
    background: var(--surface3);
    color: var(--accent);
}

/* 検索バー (中央固定) */
.shell-search {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 560px;
    height: 32px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0 4px 0 12px;
    transition: border-color 0.15s, background 0.15s;
}
.shell-search:focus-within {
    border-color: var(--accent);
    background: var(--surface);
}
.shell-search-icon {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.1s, color 0.1s;
}
.shell-search-icon:hover { color: var(--text); background: var(--surface3); }
.shell-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 13px;
    padding: 4px 8px;
    height: 100%;
    min-width: 0;
}
.shell-search-input::placeholder {
    color: var(--text-muted);
}

/* アカウントボタン */
.shell-btn-account {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--surface3);
    border-radius: 16px;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.shell-btn-account:hover {
    background: var(--surface3);
    color: var(--text);
    border-color: var(--accent);
}

.shell-ble-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 10px;
    background: var(--surface3);
}
.shell-ble-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
.shell-ble-status.connected .shell-ble-dot {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16,185,129,0.5);
}
.shell-ble-status.connected {
    color: var(--success);
}

.shell-btn-devices {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
.shell-btn-devices:hover {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
}
.shell-btn-devices:active {
    transform: translateY(1px);
}

/* ===== View ルート ===== */
/* デフォルトは縦スクロール可能。Sequencer のように独自レイアウトを持つ View は
   内部コンテナで overflow:hidden を指定する（.sequencer-view-container など）。 */
.view-root {
    height: calc(100vh - var(--shell-header-h));
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sequencer View 専用: 元の CSS が body(100vh, flex-column) 前提のため、
   コンテナを同等の flex column にしてやる */
.sequencer-view-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.view-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== トースト (shell 共通) ===== */
.shell-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    max-width: 320px;
}
.shell-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.shell-toast.ok { border-color: var(--success); color: var(--success); }
.shell-toast.err { border-color: var(--danger); color: var(--danger); }
.shell-toast.warn { border-color: var(--warn); color: var(--warn); }

/* ===== ドキュメントページ (利用規約 / プライバシー / About) ===== */
.static-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    line-height: 1.8;
    color: var(--text-dim);
}
.static-page h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 8px;
}
.static-page .static-page-meta {
    color: var(--text-muted);
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.static-page h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 36px 0 12px;
    padding-top: 4px;
}
.static-page h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 8px;
}
.static-page p { margin: 0 0 12px; }
.static-page ul, .static-page ol {
    margin: 0 0 16px;
    padding-left: 24px;
}
.static-page li { margin: 4px 0; }
.static-page a {
    color: var(--accent);
    text-decoration: none;
}
.static-page a:hover { text-decoration: underline; }
.static-page strong { color: var(--text); font-weight: 600; }
.static-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 13px;
}
.static-page table th, .static-page table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.static-page table th {
    color: var(--text);
    background: var(--surface2);
    font-weight: 600;
}
.static-page hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}
.static-page .static-page-toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 32px;
}
.static-page .static-page-toc-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}
.static-page .static-page-toc ol { padding-left: 18px; margin: 0; }
.static-page .static-page-toc a { color: var(--text-dim); font-size: 13px; }
.static-page .static-page-toc a:hover { color: var(--accent); }
.static-page .callout {
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 4px;
}
.static-page .callout strong { color: var(--accent); }
.static-page-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 24px;
    cursor: pointer;
}
.static-page-back:hover { color: var(--accent); }

/* ============ 対応機種モーダル ============ */
.btn-link {
    background: transparent;
    border: none;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 12px;
}
.btn-link:hover { color: var(--accent-dim); }
.supported-devices-list {
    list-style: none;
    padding: 0;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface2);
}
.supported-devices-list li {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
}
.supported-devices-list li:last-child { border-bottom: none; }

/* ============ BLE 接続同意モーダル ============ */
.ble-consent-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
    max-height: 320px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}
.ble-consent-heading {
    font-size: 14px;
    margin: 0 0 10px;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}
.ble-consent-lead {
    margin: 0 0 10px;
    font-weight: 600;
}
.ble-consent-list {
    margin: 0 0 12px;
    padding-left: 20px;
}
.ble-consent-list li {
    margin-bottom: 4px;
}
.ble-consent-warn {
    margin: 10px 0 0;
    padding: 10px 12px;
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--warn);
    border-radius: 4px;
    font-size: 12px;
}
.ble-consent-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 12px 0;
    cursor: pointer;
    user-select: none;
}
.ble-consent-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.ble-consent-check span {
    font-size: 14px;
    color: var(--text);
}
.ble-consent-check:has(input:checked) {
    border-color: var(--accent);
    background: rgba(255, 137, 59, 0.08);
}

/* ============ 未ログイン誘導吹き出し ============ */
.shell-onboard-tip {
    position: fixed;
    top: calc(var(--shell-header-h) + 10px);
    right: 24px;                  /* ログインボタン直下寄りに配置 */
    z-index: 950;
    background: linear-gradient(135deg, var(--accent), #ff6b3b);
    color: #fff;
    padding: 12px 36px 12px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(255, 137, 59, 0.35), 0 2px 6px rgba(0,0,0,0.2);
    max-width: 280px;
    animation: shell-onboard-bounce 0.5s ease-out;
}
.shell-onboard-tip-arrow {
    position: absolute;
    top: -8px;
    /* left は JS で動的に「ペンライト接続」ボタン中心に合わせる (positionOnboardTipArrow) */
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--accent);
}
.shell-onboard-tip-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.shell-onboard-tip-close:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.shell-onboard-tip-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}
.shell-onboard-tip-sub {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.95;
}
@keyframes shell-onboard-bounce {
    0%   { opacity: 0; transform: translateY(-12px); }
    60%  { opacity: 1; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}
@media (max-width: 640px) {
    .shell-onboard-tip {
        right: 8px;
        left: 8px;
        max-width: none;
    }
    /* 矢印の left 位置は JS で動的決定 (positionOnboardTipArrow) */
}


/* ===== 演出種別バッジ (ライブ再現 / オリジナル) ===== */
.ll-style-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    user-select: none;
}
.ll-style-badge.is-live {
    color: #ff5fa3;
    background: rgba(255,95,163,0.12);
    border-color: rgba(255,95,163,0.35);
}
.ll-style-badge.is-original {
    color: #6ae6c1;
    background: rgba(106,230,193,0.12);
    border-color: rgba(106,230,193,0.35);
}
