/* =========================================
   Philarium Common Styles
   ========================================= */

/* --- Variables (Fallback) --- */
:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --accent: #38bdf8;
    --input-bg: #0f172a;
    --border-color: #334155;
    --code-bg: #0d1117;
}

/* --- Base Settings (from before.html) --- */
html {
    -webkit-text-size-adjust: 100%;
}

/* ズーム禁止・操作性向上 (hypomnemata.htmlより適用) */
*,
*::before,
*::after {
    touch-action: pan-x pan-y;
    /* ピンチズーム無効化 */
}

input,
textarea,
a,
button,
[contenteditable="true"] {
    touch-action: manipulation;
    /* 入力要素などは操作可能に */
}

body {
    margin: 0;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overscroll-behavior: none;
    /* バウンススクロール無効化 */
}

/* 入力欄などは選択・操作可能にする */
input,
textarea,
a,
button {
    -webkit-user-select: text;
    user-select: text;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
    cursor: pointer;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* --- Standard Header --- */
header.portfolio-header,
header.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    box-sizing: border-box;
}

header.portfolio-header .logo,
header.site-header .logo {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
    flex-shrink: 0;
    color: var(--text-main);
    text-decoration: none;
}

header.portfolio-header nav ul,
header.site-header nav ul {
    display: flex;
    gap: 30px;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

header.portfolio-header nav a,
header.site-header nav a {
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-main);
    transition: 0.3s;
    cursor: pointer;
}

header.portfolio-header nav a:hover,
header.site-header nav a:hover {
    color: var(--accent);
}

@media (max-width: 768px) {

    header,
    header.portfolio-header,
    header.site-header {
        padding: 15px 20px;
    }

    header .logo,
    header.portfolio-header .logo,
    header.site-header .logo {
        font-size: 1rem;
    }

    header nav ul,
    header.portfolio-header nav ul,
    header.site-header nav ul {
        gap: 15px;
    }

    header nav a,
    header.portfolio-header nav a,
    header.site-header nav a {
        font-size: 0.85rem;
    }
}

/* --- Modal (Unified) --- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

.modal-card {
    background: var(--card-bg, #1e293b);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border-color, #334155);
    text-align: center;
    width: 380px;
    box-sizing: border-box;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: zoom 0.2s;
}

.modal-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.modal-message {
    color: var(--text-sub, #94a3b8);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.modal-input {
    width: 100%;
    background: var(--input-bg, #0f172a);
    border: 1px solid var(--border-color, #334155);
    color: var(--text-main, #f1f5f9);
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 2px;
}

.modal-input:focus {
    border-color: var(--accent, #38bdf8);
}

.modal-input::placeholder {
    transition: opacity 0.2s;
    color: var(--text-sub, #94a3b8);
    opacity: 0.5;
}

.modal-input:focus::placeholder {
    opacity: 0;
}

.modal-btn {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 10px;
}

.btn-primary {
    background: var(--accent, #38bdf8);
    color: #0f172a;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--text-sub, #94a3b8);
    color: var(--text-sub, #94a3b8);
}

.btn-cancel:hover {
    border-color: var(--text-main, #f1f5f9);
    color: var(--text-main, #f1f5f9);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoom {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Loading Overlay (Referenced from hypomnemata.html) --- */
#loading-overlay,
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(56, 189, 248, 0.3);
    border-top: 5px solid var(--accent, #38bdf8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: var(--accent, #38bdf8);
    font-weight: bold;
    letter-spacing: 2px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }

    100% {
        transform: rotate(360deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Red Theme for Delete Loading */
.loading-overlay.theme-danger .spinner {
    border-color: rgba(239, 68, 68, 0.3);
    border-top-color: var(--danger, #ef4444);
}

.loading-overlay.theme-danger .loading-text {
    color: var(--danger, #ef4444);
}

/* --- Action Modal (Moved from filter-toolbar.css) --- */
.action-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

.action-card {
    background: var(--card-bg, #1e293b);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border-color, #334155);
    text-align: center;
    width: 300px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: zoom 0.2s;
}

.action-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: bold;
}

.action-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.95rem;
}

.btn-merge-and {
    background: var(--accent, #38bdf8);
    color: #0f172a;
}

.btn-merge-or {
    background: #f472b6;
    color: #0f172a;
}

.btn-decompose {
    background: #ef4444;
    color: #fff;
}

.btn-select {
    background: #10b981;
    color: #0f172a;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--text-sub, #94a3b8);
    color: var(--text-sub, #94a3b8);
}

.btn-delete-confirm {
    background: #ef4444;
    color: #fff;
}

.btn-delete-confirm:hover {
    background: #dc2626;
}