/* Tags container - fix alignment */
#tags_container,
#mytags {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    text-align: left !important;
}

#mytags a.tag {
    flex: 0 0 auto !important;
    margin: 0 !important;
}

/* ===== Landing Page Styles ===== */

/* Hide inline title and properties on landing page */
body.landing-page .inline-title,
body.landing-page .view-header-title,
body.landing-page .mod-header,
body.landing-page .frontmatter-container,
body.landing-page .metadata-container {
    display: none !important;
}

/* Match background color to header image (pure black) */
body.landing-page .workspace-leaf-content,
body.landing-page .view-content,
body.landing-page .markdown-preview-view,
body.landing-page .markdown-rendered {
    /* background reverted to default */
}

/* ===== Hero: pure CSS, no JS DOM manipulation ===== */

/* Image container — full bleed with gradient ::after */
body.landing-page #mdContent > p:has(> a > img) {
    position: relative !important;
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    height: 360px !important;
    overflow: hidden !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

body.landing-page #mdContent > p:has(> a > img) img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
}

body.landing-page #mdContent > p:has(> a > img) a {
    display: block !important;
    height: 100% !important;
}

/* Gradient overlay on image */
body.landing-page #mdContent > p:has(> a > img)::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 55%;
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.8));
    pointer-events: none;
}

/* h1 — negative margin to overlap image */
body.landing-page #mdContent > h1:first-of-type {
    position: relative !important;
    z-index: 2 !important;
    margin-top: -2.8em !important;
    margin-bottom: 0.4em !important;
    color: #fff !important;
    font-size: 2.4em !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
    line-height: 1.2 !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

/* Copy-link icon inside h1 */
body.landing-page #mdContent > h1:first-of-type .copy-icon {
    display: none !important;
}

/* Tagline blockquote — negative margin to overlap image */
body.landing-page #mdContent > h1:first-of-type + blockquote,
body.landing-page #mdContent > h1:first-of-type + blockquote p {
    position: relative !important;
    z-index: 2 !important;
    margin-top: -0.8em !important;
    margin-bottom: 1.5em !important;
    color: rgba(255,255,255,0.9) !important;
    font-size: 1.05em !important;
    font-weight: 300 !important;
    font-style: italic !important;
    border-left: none !important;
    background: none !important;
    padding: 0 !important;
    text-shadow: 0 1px 6px rgba(0,0,0,0.5) !important;
    text-align: left !important;
}

/* Mobile hero */
@media screen and (max-width: 990px) {
    body.landing-page #mdContent > p:has(> a > img) {
        height: 320px !important;
        /* ensure full-bleed even with mobile padding */
        margin-left: calc(-50vw + 50% - 8px) !important;
        width: calc(100vw + 16px) !important;
    }
    body.landing-page #mdContent > h1:first-of-type {
        font-size: 1.6em !important;
        margin-top: -2.6em !important;
        margin-bottom: 0.3em !important;
    }
    body.landing-page #mdContent > h1:first-of-type + blockquote,
    body.landing-page #mdContent > h1:first-of-type + blockquote p {
        font-size: 0.85em !important;
        margin-top: 0 !important;
    }
}

/* Landing page callout cards — neutral gray */
body.landing-page .callout {
    margin-bottom: 12px !important;
    border-radius: 8px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1) !important;
}

body.landing-page .callout-title-inner,
body.landing-page .callout .callout-icon {
    color: rgba(255,255,255,0.8) !important;
}

body.landing-page .callout:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}

body.landing-page .callout-title {
    font-size: 1.1em !important;
    font-weight: 600 !important;
}

body.landing-page .callout-content {
    font-size: 0.9em !important;
    opacity: 0.85 !important;
}

/* (Hero tagline styles handled via negative-margin approach above) */

/* Section headers */
body.landing-page h2 {
    margin-top: 2em !important;
    padding-bottom: 0.5em !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}

/* Topics section - compact list */
body.landing-page h3 {
    margin-top: 1.5em !important;
    margin-bottom: 0.5em !important;
}

body.landing-page ul {
    margin-top: 0.25em !important;
}


/* ===== Hide content-area graph-controls (font-size is now A-/A+ in header) ===== */
.markdown-preview-sizer > .graph-controls {
    display: none !important;
}

/* ===== Graph Expansion (Desktop & Mobile共通) ===== */
/* 右パネルの親要素チェーンに高さを伝搬させてグラフを最下部まで拡張 */

.mod-right-split .workspace-tabs {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
}

.mod-right-split .workspace-tab-container {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mod-right-split .workspace-leaf {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mod-right-split .workspace-leaf-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mod-right-split .view-content {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mod-right-split .nav-header {
    flex: 0 0 auto !important;
}

.backlink-pane {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
}

#tags_container {
    flex: 0 0 auto !important;
    overflow-y: auto !important;
}

#localGraph {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
}

#localGraph #graph {
    flex: 0 0 auto !important;
}

#localGraph #mynetwork {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
}

/* ===== Graph Controls (Desktop & Mobile共通) ===== */

#localGraph #graph {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

#mobile-graph-gear {
    display: inline !important;
    cursor: pointer !important;
    opacity: 0.5 !important;
    font-size: 20px !important;
    transition: opacity 0.2s !important;
    line-height: 1 !important;
}

#mobile-graph-gear:hover,
#mobile-graph-gear.is-active {
    opacity: 1 !important;
}

#mobile-graph-controls {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 8px 12px !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 56px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    background: var(--background-secondary-alt, #262626) !important;
    overflow-y: auto !important;
    max-height: 60% !important;
    z-index: 10 !important;
}

#mobile-graph-controls.is-closed {
    display: none !important;
}

#mobile-graph-controls .mgc-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 6px !important;
    font-size: 12px !important;
    color: var(--text-muted, #999) !important;
}

#mobile-graph-controls .mgc-row label {
    flex: 0 0 80px !important;
    text-align: right !important;
}

#mobile-graph-controls .mgc-row input[type="range"] {
    flex: 1 !important;
    height: 4px !important;
}

#mobile-graph-controls .mgc-row .mgc-val {
    flex: 0 0 36px !important;
    text-align: left !important;
    font-family: monospace !important;
    font-size: 11px !important;
}

/* ===== Mobile Right Panel Drawer ===== */
/* perlite.css が @media (max-width:990px) で右パネルとトグルを display:none にするため上書き */
@media screen and (max-width: 990px) {
    /* トグルボタンを表示 */
    .sidebar-toggle-button.mod-right {
        display: flex !important;
    }

    /* 右パネルを slide-in drawer に変換 */
    .workspace-split.mod-horizontal.mod-right-split {
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        width: min(300px, 85vw) !important;
        height: 100vh !important;
        z-index: 200 !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease !important;
        background-color: var(--background-secondary, #1e1e1e) !important;
        overflow-y: auto !important;
        box-shadow: none !important;
    }

    /* drawer 開いた状態 */
    .workspace.is-right-sidedock-open .workspace-split.mod-horizontal.mod-right-split {
        transform: translateX(0) !important;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5) !important;
    }

    /* バックドロップ */
    .workspace.is-right-sidedock-open::after {
        content: '' !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.5) !important;
        z-index: 199 !important;
        pointer-events: auto !important;
    }

    /* drawer 内のスクロールを無効化（flex レイアウトで高さ制御） */
    .workspace-split.mod-horizontal.mod-right-split {
        overflow-y: hidden !important;
    }

    /* Tags はモバイルで最大高さ制限 */
    #tags_container {
        max-height: 180px !important;
    }

}

/* ===== Font Settings (matching Obsidian) ===== */
/* 英語: Charter (論文向けセリフ体), 日本語: Noto Sans JP */

body,
.markdown-preview-view,
.markdown-rendered,
.view-content {
    font-family: "Charter", "CharterBT-Roman", "Noto Sans JP", Georgia, serif !important;
    line-height: 1.7 !important;
}

/* 等幅フォント（コードブロック用） */
code,
pre,
.cm-s-obsidian .cm-inline-code,
.markdown-preview-view code {
    font-family: "JetBrains Mono", "SF Mono", Menlo, monospace !important;
}

/* ===== Inline Comments ===== */

/* Commentable paragraph — base */
.commentable {
    position: relative;
}

/* --- Toolbar toggle button --- */
#comment-toggle {
    position: relative;
}

#comment-toggle.is-active {
    color: var(--interactive-accent, #7b6cd9);
}

/* Comment count on toolbar button */
.comment-toggle-count {
    position: absolute;
    top: -4px;
    right: -6px;
    background: var(--interactive-accent, #7b6cd9);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    border-radius: 50%;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    pointer-events: none;
}

/* --- Comment badge (always visible on paragraphs with comments) --- */
.comment-badge {
    position: absolute;
    right: 4px;
    top: 2px;
    background: var(--interactive-accent, #7b6cd9);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    z-index: 5;
}

.comment-badge:hover {
    opacity: 1;
}

/* --- Comment mode active: paragraph highlighting --- */
.comment-mode-active .commentable {
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
}

.comment-mode-active .commentable:hover {
    background: rgba(123, 108, 217, 0.08);
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
    .comment-badge {
        min-width: 20px;
        height: 20px;
        line-height: 20px;
        font-size: 10px;
        opacity: 0.7;
        padding: 4px;
        margin: -4px;
    }

    .comment-input {
        font-size: 16px;
    }
}

/* Comment panel (inline, below paragraph) */
.comment-panel {
    background: var(--background-secondary, #262626);
    border: 1px solid var(--background-modifier-border, #333);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.comment-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--background-modifier-border, #333);
}

.comment-panel-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-normal, #ddd);
}

.comment-panel-close {
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--text-muted, #999);
    padding: 0 4px;
}

.comment-panel-close:hover {
    color: var(--text-normal, #ddd);
}

/* Individual comment */
.comment-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--background-modifier-border-hover, #3a3a3a);
}

.comment-item:last-of-type {
    border-bottom: none;
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-muted, #999);
}

.comment-author {
    font-weight: 600;
    color: var(--text-accent, #7b6cd9);
}

.comment-time {
    opacity: 0.7;
}

.comment-delete {
    margin-left: auto;
    cursor: pointer;
    color: var(--text-faint, #666);
    font-size: 11px;
}

.comment-delete:hover {
    color: var(--text-error, #e55);
}

.comment-body {
    color: var(--text-normal, #ddd);
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-empty {
    color: var(--text-faint, #666);
    font-style: italic;
    padding: 4px 0;
}

/* Input area */
.comment-input-area {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--background-modifier-border, #333);
}

.comment-input {
    width: 100%;
    background: var(--background-primary, #1e1e1e);
    color: var(--text-normal, #ddd);
    border: 1px solid var(--background-modifier-border, #333);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    box-sizing: border-box;
    -webkit-user-modify: read-write-plaintext-only !important;
    user-modify: read-write-plaintext-only !important;
}

.comment-input:focus {
    outline: none;
    border-color: var(--interactive-accent, #7b6cd9);
}

.comment-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.comment-input-user {
    font-size: 12px;
    color: var(--text-muted, #999);
}

.comment-post-btn {
    background: var(--interactive-accent, #7b6cd9);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.comment-post-btn:hover {
    opacity: 0.85;
}

.comment-post-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Mobile adjustments ===== */
@media screen and (max-width: 990px) {
    .comment-panel {
        margin-left: -8px;
        margin-right: -8px;
        border-radius: 6px;
    }
}
