/* --- Base Setup --- */
:root {
    --indigo-primary: #6366f1;
    --indigo-hover: #4f46e5;
    --bg-main: #fcfcfc;
    --sidebar-bg: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-light: #eee;
}

body {
    font-family: "Inter", "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    overflow: hidden; /* 全体のスクロールは禁止、各エリアで制御 */
}

.logo-nelu {
    width: 160px;
    margin: 0 auto;
    font-family: "Borel", cursive;
    font-weight: 400;
    /* letter-spacing: -0.02em; 少し文字間を詰めるとよりロゴっぽくなります */
}
.logo-nelu img {
    width: 100%;
}
.logo-nelu-side img {
    width: 80px;
}
.logo-nelu-sp img {
    width: 60px;
}

#outline-container {
    max-width: 800px !important;
    margin: 0 auto !important;
}

/* モバイルタブのスクロールバーを隠す */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- Layout Components --- */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

/* --- Editor Typography & Reset --- */
/* リッチテキストの書式を強制リセット（コピペ対策） */
.node-content *, .node-title * {
    all: unset;
    display: inline;
}

.node-content img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* --- Sidebar Specific --- */
#tree-display {
    user-select: none;
}

.sidebar-handle {
    cursor: grab;
}
.sidebar-handle:active {
    cursor: grabbing;
}

/* --- Outline Node Decorations --- */
/* 子要素のインデントを示すガイドライン */
.outline-node {
    position: relative;
}

/* ルート以外のノードに左線を引き、階層を視覚化する */
.outline-node:not([style*="margin-left: 0rem"])::before {
    content: "";
    position: absolute;
    left: 0.45rem; /* defaultCss -0.5rem */
    top: -0.75rem;
    bottom: -0.75rem; /* 次のノードへの繋がり */
    width: 1px;
    background: var(--border-light);
}

/* ドラッグ中のスタイル (Sortable.js) */
.sortable-ghost {
    opacity: 0.3;
    background: var(--indigo-primary) !important;
}

.sortable-chosen {
    background: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out forwards;
}

/* --- Toast (Undo) Notification Area --- */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    font-size: 0.875rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.node-content {
    display: block; 
    unicode-bidi: plaintext;
    min-height: 1.5em;
    padding: 8px 12px;
    /* 枠線を最初から実線（透明）で固定しておく。太さを変えないのがコツ */
    border: 1px solid transparent; 
    border-radius: 8px; /* rounded-xlに合わせて少し調整 */
    transition: all 0.2s ease;
    line-height: 1.6;
    white-space: normal !important;
    word-break: break-all;
    overflow-wrap: break-word;
}

.node-content:focus {
    outline: none;
    /* 枠線の太さは 1px のまま、色だけ変える */
    border-color: #6366f1;
    /* 外側に光るエフェクトを box-shadow で作る（これはサイズに影響しない） */
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background-color: white; /* 集中しやすいように白背景に */
}

/* .node-content:hover {
    border-color: #e2e8f0;
} */

/* リンクの基本スタイル */
.node-content a {
    color: var(--indigo-primary);
    text-decoration: underline;
    cursor: pointer;
    pointer-events: auto; /* 編集モードでもクリック可能にする */
}

/* リンクの上にマウスを置いた時の視覚効果 */
.node-content a:hover {
    color: var(--indigo-hover);
}

/* リンクボタンのスタイル */
.node-content button[contenteditable="false"] {
    user-select: none;
    cursor: pointer;
    vertical-align: middle;
    display: inline-flex;
    margin-right: 4px;
}

/* 編集中のカーソルがボタンに吸い込まれないようにする */
.node-content button {
    pointer-events: auto;
}

.node-title:empty:before {
    content: "無題のノード";
    color: #cbd5e1; /* slate-300 */
    pointer-events: none;
}
.node-title {
    min-width: 50px;
    min-height: 1.5em;
    display: inline-block; /* または block */
}

/* フィルターがONのとき、一度すべて消す（!importantを最強にする） */
body #outline-container[data-active-filter] .outline-node {
    display: none !important;
}

/* 一致するステータスのノード、または一番最初のノード（ルート）は表示 */
body #outline-container[data-active-filter="未着手"] .outline-node[data-status="未着手"],
body #outline-container[data-active-filter="進行中"] .outline-node[data-status="進行中"],
body #outline-container[data-active-filter="完了"] .outline-node[data-status="完了"],
body #outline-container[data-active-filter="保留"] .outline-node[data-status="保留"],
body #outline-container[data-active-filter="要確認"] .outline-node[data-status="要確認"],
body #outline-container[data-active-filter="アイデア"] .outline-node[data-status="アイデア"],
body #outline-container[data-active-filter] .outline-node:first-of-type {
    display: block !important;
}

/* ノードの表示・非表示に滑らかな変化をつける */
.outline-node {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* display: none の代わりに opacity と height で制御したい場合は高度になりますが、
   今の JS 操作 (display: block/none) のままでも、
   表示される瞬間にふわっと出すことは可能です */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.outline-node[style*="display: block"] {
    animation: fadeIn 0.3s ease forwards;
}

/* アクションメニューの制御 */
.action-menu {
    /* 常に場所は確保するが透明にする、あるいは非表示にする */
    pointer-events: none; 
}

.group:hover .action-menu {
    opacity: 1;
    pointer-events: auto;
}

/* タイトルとバッジの親要素を調整 */
.node-header {
    min-height: 40px;
    border-radius: 12px;
    padding: 4px 12px;
    transition: background-color 0.2s;
}

.node-header:hover {
    background-color: rgba(248, 250, 252, 0.8); /* 非常に薄いグレー */
}

/* 編集不可な要素のスタイル */
[contenteditable="false"] {
    cursor: default;
    background-color: transparent !important;
}
/* 編集可能な要素はホバーで少し色を変える */
[contenteditable="true"]:hover {
    background-color: rgba(99, 102, 241, 0.05);
}

/* ノード追加時のハイライト */
@keyframes highlight-fade {
    0% { background-color: #e0e7ff !important; } /* indigo-100 */
    100% { background-color: transparent !important; }
}

/* クラスがついた要素そのものと、その直下の主要な子要素も光らせる */
.new-node-highlight, 
.new-node-highlight > div,
.new-node-highlight .flex-1 {
    animation: highlight-fade 2.0s ease-out forwards !important;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin-slow {
    animation: spin-slow 2s linear infinite;
}
.uploading-opacity {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* ドラッグ中のテキスト選択を無効化 */
.index-node-item {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ドラッグ中の見た目をスッキリさせる */
.index-node-item.opacity-50 {
    opacity: 0.5;
    background: #f8fafc; /* slate-50 */
}

/* ドラッグが有効になった（長押し完了）瞬間のスタイル */
.sortable-chosen {
    background-color: #f1f5f9 !important; /* slate-100: 少し色を変える */
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); /* 影をつけて浮かせる */
    transform: scale(1.02); /* ほんの少し大きくする */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 50;
    border-color: #e2e8f0 !important;
}

/* 実際に移動させている最中の見た目（ゴースト） */
.sortable-ghost {
    opacity: 0.3;
    background-color: #e2e8f0 !important;
}

/* 削除時のアニメーション：左へスライドしながらフェードアウト */
.node-delete-animation {
    pointer-events: none; /* アニメーション中は操作不能にする */
    animation: node-slide-out 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes node-slide-out {
    0% {
        opacity: 1;
        transform: translateX(0);
        max-height: 200px; /* 十分な高さを保持 */
    }
    30% {
        opacity: 0.7;
        transform: translateX(-15px);
    }
    100% {
        opacity: 0;
        transform: translateX(-60px);
        max-height: 0;
        margin-top: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        overflow: hidden;
    }
}

/* 復活時のアニメーション：右からスライドイン */
.node-undo-animation {
    animation: node-slide-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    overflow: hidden;
}

@keyframes node-slide-in {
    0% {
        opacity: 0;
        transform: translateX(30px) scale(0.98);
        max-height: 0;
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 200px; /* 削除時のアニメーションと合わせる */
    }
}

@media all and (max-width: 768px) {
    .logo-nelu {
        width: 100px;
    }
}