/* --- Variables & Basic Styles --- */
:root {
    --bg-color: #f8f8f8;
    --text-color: #1a1a1a;
    --card-bg-color: #ffffff;
    --border-color: #e6e6e6;
    --accent-color: #007aff;
    --secondary-text-color: #6e6e73;
    --sidebar-width: 260px;

    /* 検索ボックスの基準幅と最大幅（拡張時） */
    --search-base: 440px;
    --search-max: 560px;
}
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}
.page-wrapper { display: flex; height: 100%; }

/* --- Sidebar --- */
.sidebar { width: var(--sidebar-width); background-color: #ffffff; border-right: 1px solid var(--border-color); height: 100%; position: relative; z-index: 1000; display: flex; flex-direction: column; flex-shrink: 0; transition: margin-left 0.3s ease-in-out; }
.page-wrapper.sidebar-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-width)); }
.sidebar-content { flex-grow: 1; overflow-y: auto; padding: 24px; }
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding-bottom: 24px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); text-decoration: none; color: inherit; }
.sidebar-logo img { width: 40px; height: 40px; -webkit-user-drag: none; user-select: none; }
.sidebar-logo span { font-size: 20px; font-weight: 600; }
.sidebar-header { margin-bottom: 16px; }
.filters .filter-group { margin-bottom: 24px; }
.filters h4 { margin: 0 0 16px 0; color: var(--secondary-text-color); font-size: 14px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.company-group { margin-bottom: 18px; }
.company-name { font-size: 16px; font-weight: 600; margin: 0 0 14px 0; }
.service-list { padding-left: 20px; }
.filter-item { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; cursor: pointer; user-select: none; }
.filter-label-text { font-size: 16px; line-height: 1; }
.checkBox { display: block; width: 12px; height: 12px; border-radius: 3px; position: relative; overflow: hidden; box-shadow: 0px 0px 0px 2px var(--text-color); flex-shrink: 0; }
.checkBox .transition { width: 60px; height: 60px; background-color: var(--text-color); top: -52px; left: -52px; position: absolute; transform: rotateZ(45deg); z-index: 100; transition: 300ms ease; }
.filter-item input[type="checkbox"] { position: absolute; opacity: 0; height: 0; width: 0; }
.filter-item input[type="checkbox"]:checked ~ .checkBox .transition { left: -10px; top: -10px; }
.sidebar-user-profile { border-top: 1px solid var(--border-color); padding: 20px 24px 18px; display: flex; align-items: center; justify-content: flex-start; gap: 14px; flex-shrink: 0; border-radius: 12px; position: relative; transition: background-color 360ms cubic-bezier(0.22, 0.68, 0, 1), border-color 360ms cubic-bezier(0.22, 0.68, 0, 1), box-shadow 360ms cubic-bezier(0.22, 0.68, 0, 1); }
.sidebar-user-profile.is-logged-in { background-color: rgba(0, 122, 255, 0.06); border-color: rgba(0, 122, 255, 0.2); box-shadow: 0 3px 9px rgba(0, 122, 255, 0.08); cursor: pointer; }
.sidebar-user-profile.is-logged-in.is-hover { background-color: rgba(0, 122, 255, 0.12); border-color: rgba(0, 122, 255, 0.32); box-shadow: 0 10px 24px rgba(0, 122, 255, 0.14); justify-content: center; }
.user-avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, rgba(255,255,255,0.4), rgba(255,255,255,0)); display: grid; place-items: center; overflow: hidden; position: relative; flex-shrink: 0; transition: box-shadow 320ms cubic-bezier(0.33, 1, 0.68, 1), transform 320ms cubic-bezier(0.33, 1, 0.68, 1); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05), 0 2px 6px rgba(0,0,0,0.06); }
.sidebar-user-profile.is-logged-in.is-hover .user-avatar { box-shadow: inset 0 0 0 1px rgba(122,174,255,0.45), 0 6px 16px rgba(122,174,255,0.18); transform: translateY(-1px); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: none; }
.user-avatar.has-photo img { display: block; }
.user-icon { font-size: 28px; color: #aeb4c2; transition: transform 360ms cubic-bezier(0.33, 1, 0.68, 1), color 360ms cubic-bezier(0.33, 1, 0.68, 1); }
.user-avatar.has-photo .user-icon { display: none; }
.sidebar-user-profile.is-logged-in.is-hover .user-icon { transform: translateY(-1px); color: #7aaeff; }
.user-info { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; transition: transform 360ms cubic-bezier(0.33, 1, 0.68, 1), align-items 200ms ease, text-align 200ms ease; }
.sidebar-user-profile.is-logged-in.is-hover .user-info { transform: translateY(-1px); align-items: center; text-align: center; }
.user-name { font-weight: 600; }
.user-status { font-size: 13px; color: var(--secondary-text-color); transition: opacity 280ms cubic-bezier(0.33, 1, 0.68, 1), transform 280ms cubic-bezier(0.33, 1, 0.68, 1), max-height 320ms cubic-bezier(0.22, 0.68, 0, 1); max-height: 20px; overflow: hidden; }
.sidebar-user-profile.is-logged-in.is-hover .user-status { opacity: 0; transform: translateY(-6px); max-height: 0; }

/* --- Main Content & Header Layout --- */
.main-content { flex-grow: 1; height: 100vh; overflow-y: auto; }

/* ヘッダー（崩れ対策済み） */
.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    position: sticky; /* 絶対配置（検索・フィルター）の基準 */
    top: 0;
    z-index: 900;
}
.header-left, .header-center, .header-right { display: flex; align-items: center; min-width: 0; }
.header-left { gap: 16px; justify-content: flex-start; }
.header-center { justify-content: center; } /* 中央カラムは表示用。検索自体は絶対配置で中央固定 */
.header-right { gap: 12px; justify-content: flex-end; white-space: nowrap; }

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo .header-logo-icon { width: 32px; height: 32px; -webkit-user-drag: none; user-select: none; }
.logo span { font-size: 22px; font-weight: 600; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-color); padding: 8px; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s ease; }
.icon-btn:hover { background-color: rgba(0,0,0,0.05); }

/* ===== 検索：常にヘッダーど真ん中。拡張は search:focus-within のみで発火 ===== */
.search {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: var(--search-base);
    max-width: var(--search-max);
    min-width: 240px;
    z-index: 902;
    transition: width .25s cubic-bezier(.2,.7,.3,1); /* スムーズ（以前の挙動に戻す） */
}
.search:focus-within {
    width: var(--search-max); /* クリックで発火するのは検索内のみ（フィルターでは発火しない） */
}
.search__input { width: 100%; min-width: 0; padding: 10px 40px 10px 20px; border: 1px solid var(--border-color); border-radius: 20px; font-size: 16px; background-color: var(--bg-color); transition: box-shadow 0.2s ease, background-color .2s ease; }
.search__input:focus { outline: 1px solid var(--accent-color); background-color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.search__button { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; padding: 8px; }
.search__icon { width: 20px; height: 20px; fill: var(--secondary-text-color); }

/* ===== フィルター：常に右側。検索最大幅ぶんスペースを確保し、検索拡張の影響を受けない ===== */
.sort-switcher,
.filter-switcher {
    position: absolute;
    right: calc(50% + var(--search-max) / 2 + 16px); /* 検索の最大幅の“右端”から一定距離に固定 */
    top: 50%;
    transform: translateY(-50%);
    z-index: 901;
    width: max-content; /* ラベルが長くなると左にだけ広がる */
}

/* Header Buttons */
.glass-btn, .login-btn, .lang-btn { padding: 10px 20px; border-radius: 8px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; border: 1px solid transparent; white-space: nowrap; }
.glass-btn { background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-color: rgba(0, 0, 0, 0.1); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.glass-btn:hover { background: rgba(255, 255, 255, 0.4); }
.login-btn { background-color: var(--accent-color); color: white; }
.login-btn:hover { background-color: #0056b3; }

/* 言語切替（既存） */
.language-switcher { position: relative; }
.lang-btn { background: none; border-color: var(--border-color); display: flex; align-items: center; gap: 8px; }
.lang-btn:hover { background-color: rgba(0,0,0,0.05); }
.lang-btn .arrow-icon { font-size: 12px; }
.lang-menu { position: absolute; top: calc(100% + 8px); right: 0; background-color: white; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); list-style: none; padding: 8px; margin: 0; width: 150px; z-index: 1000; opacity: 0; visibility: hidden; transform: translateY(10px); transition: opacity 0.2s ease, transform 0.2s ease; }
.lang-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }
.lang-menu li a { display: block; padding: 8px 12px; color: var(--text-color); text-decoration: none; border-radius: 4px; }
.lang-menu li a:hover { background-color: #f0f0f0; }

/* --- Gallery & Cards --- */
.container { padding: 24px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }

.prompt-card { background-color: var(--card-bg-color); border-radius: 12px; overflow: hidden; border: 1px solid var(--border-color); display: flex; flex-direction: column; cursor: pointer; transition: box-shadow 0.2s ease, transform 0.2s ease; }
.prompt-card:hover { transform: translateY(-5px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }

/* サムネイル */
.card-thumbnail { width: 100%; height: 200px; object-fit: cover; background-color: #f0f0f0; }

/* ▼ 複数メディア用プレビューグリッド */
.thumb-grid { width: 100%; height: 200px; display: grid; gap: 2px; background: #000; }
.thumb-grid.columns-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.thumb-grid.columns-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.thumb-grid.columns-3, .thumb-grid.columns-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.thumb-cell { position: relative; overflow: hidden; background: #111; }
.thumb-cell img, .thumb-cell video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-cell .thumb-badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,0.6); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.thumb-placeholder { width: 100%; height: 100%; color: #ccc; display: grid; place-items: center; font-size: 12px; letter-spacing: 1px; }
.thumb-grid.columns-3 .thumb-cell:nth-child(3) { grid-column: 1 / -1; }

.card-content { padding: 16px; flex-grow: 1; }
.card-title { font-size: 18px; font-weight: 600; margin: 0 0 12px 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; min-height: 44px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 6px; font-weight: 500; color: white; }
.tag.secondary { background-color: #f0f0f0; color: var(--secondary-text-color); }

/* ▼ メタ行（作者＋アクション） */
.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 12px;
    background: transparent;
}
.author-name { font-size: 12px; color: var(--secondary-text-color); font-style: italic; }

.card-actions-inline { display: flex; gap: 4px; }
.action-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--secondary-text-color);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
    position: relative;
}
.action-btn:hover { background-color: #f5f5f5; color: var(--text-color); }
.action-btn:active { transform: translateY(1px); }
.action-btn .count { font-size: 14px; font-weight: 500; }
.favorite-btn.active { color: #ff4757; }
.star-btn.active { color: #ffc107; }

/* === Card Flip Animation === */
.gallery-grid { perspective: 1200px; }
.prompt-card { position: relative; transform-origin: left center; will-change: transform, box-shadow; }
.prompt-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(0,0,0,0.08), rgba(0,0,0,0) 35%); opacity: 0; transition: opacity .2s ease; border-radius: 12px; }
.prompt-card.flipping { animation: flipPage 620ms cubic-bezier(.2,.65,.2,1) both; }
.prompt-card.flipping::after { opacity: 1; }
@keyframes flipPage {
  0% { transform: rotateY(0deg) scale(1); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
  25% { transform: rotateY(-18deg) scale(1.02); box-shadow: 0 12px 28px rgba(0,0,0,0.10); }
  55% { transform: rotateY(-92deg) scale(1.0); box-shadow: 0 10px 22px rgba(0,0,0,0.08); }
  100% { transform: rotateY(-180deg) scale(0.98); box-shadow: 0 6px 16px rgba(0,0,0,0.06); }
}
@media (prefers-reduced-motion: reduce) { .prompt-card.flipping { animation: none; } }

/* --- Post & Detail Modals --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); display: none; align-items: center; justify-content: center; z-index: 2000; }
.modal-overlay.show { display: flex; }
.modal-content { background: white; padding: 30px 40px; border-radius: 12px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.close-modal-btn { position: absolute; top: 15px; right: 15px; background: none; border: none; font-size: 24px; color: #aaa; cursor: pointer; transition: color 0.2s ease; }
.close-modal-btn:hover { color: #333; }
.modal-content h2 { margin-top: 0; margin-bottom: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; }
.form-group input[type="text"], .form-group textarea { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; box-sizing: border-box; }
.form-group textarea { resize: vertical; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 15px 25px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; font-weight: normal; cursor: pointer; }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; }
.form-actions .submit-btn, .form-actions .cancel-btn { padding: 12px 24px; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; border: none; }
.submit-btn { background-color: var(--accent-color); color: white; }
.cancel-btn { background-color: #e9e9e9; color: #333; }
.file-upload-wrapper { display: flex; align-items: center; gap: 12px; }
.file-input-hidden { display: none; }
.file-upload-button { padding: 10px 15px; border-radius: 6px; background-color: #e9e9e9; color: #333; border: none; cursor: pointer; font-weight: 500; transition: background-color 0.2s; }
.file-upload-button:hover { background-color: #dcdcdc; }
.file-name-display { color: var(--secondary-text-color); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Ensure only the visible button is clickable for file selection */
label[for="post-file"] {
  pointer-events: none;
  cursor: default;
}

/* ===== My Page layout ===== */
.mypage-container { max-width: 980px; margin: 0 auto; padding: 24px; }
.mypage-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.mypage-section { margin: 28px 0; }

.feed-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.selection-controls { display: inline-flex; align-items: center; gap: 10px; }
.selection-controls .glass-btn { min-width: 88px; text-align: center; }

.pill-tabs { display: inline-flex; gap: 8px; background: #fff; border: 1px solid var(--border-color); border-radius: 999px; padding: 6px; margin-bottom: 12px; }
.pill { border: none; background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 600; color: var(--secondary-text-color); cursor: pointer; }
.pill.active { background: var(--accent-color); color: #fff; }
.pill:hover { background: rgba(0,0,0,0.04); }

.danger-btn { background-color: #ff5f56; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background-color 0.2s ease, opacity 0.2s ease; box-shadow: 0 4px 16px rgba(255,95,86,0.25); }
.danger-btn:hover { background-color: #ff3b30; }
.danger-btn:disabled { opacity: 0.5; cursor: default; }

#feed-grid { margin-top: 16px; }
#feed-grid .prompt-card { position: relative; transition: transform 0.1s ease, box-shadow 0.2s ease; }
#feed-grid.selection-mode .prompt-card { animation: wiggle 0.45s ease-in-out infinite alternate; cursor: pointer; }
#feed-grid.selection-mode .prompt-card .selection-checkbox { opacity: 1; pointer-events: auto; }
#feed-grid .prompt-card.selected { outline: 2px solid var(--accent-color); outline-offset: -2px; }

.selection-checkbox { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.95); border: 1px solid var(--border-color); border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.selection-checkbox input { appearance: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-color); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; transition: background-color 0.2s ease, border-color 0.2s ease; }
.selection-checkbox input:checked { background: var(--accent-color); border-color: var(--accent-color); }
.selection-checkbox input:checked::after { content: "\2713"; color: #fff; font-size: 11px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -55%); }

@keyframes wiggle {
  from { transform: rotate(-1.8deg); }
  to   { transform: rotate(1.8deg); }
}
.section-title { margin: 0 0 12px 0; font-size: 20px; font-weight: 700; }

.profile-card { display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: center; background: var(--card-bg-color); border: 1px solid var(--border-color); border-radius: 12px; padding: 18px; }
.avatar-large { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-color); }
.profile-form { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-row input { padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 8px; min-width: 260px; }
.actions-row { display: flex; gap: 10px; align-items: center; }
.hint { margin: 4px 0 0 0; color: var(--secondary-text-color); }

/* ▼ 投稿フォーム：プロンプト切替UI ＋ 個別入力 */
.prompt-mode {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 10px;
}
.switch {
    position: relative; width: 44px; height: 24px; display: inline-block;
}
.switch input { display: none; }
.switch .slider {
    position: absolute; cursor: pointer; inset: 0; background: #ddd; border-radius: 999px; transition: background .2s;
}
.switch .slider::before {
    content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--accent-color); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch-label { color: var(--secondary-text-color); font-size: 14px; }

#prompt-permedia-wrapper.hidden { display: none; }

/* 個別プロンプトアイテム */
.permedia-item {
    display: grid;
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
    grid-column-gap: 12px;
    grid-row-gap: 6px;
    align-items: center;
    margin-bottom: 12px;
}
.permedia-thumb {
    width: 56px; height: 56px;
    border-radius: 8px;
    background: #f0f0f0;
    overflow: hidden;
    position: relative;
    grid-row: 1 / span 2;
    display: grid; place-items: center;
}
.permedia-thumb img, .permedia-thumb video {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.permedia-file {
    font-size: 11px; color: #777; letter-spacing: .5px;
}
.permedia-badge {
    position: absolute; right: 4px; bottom: 4px;
    background: rgba(0,0,0,.6); color: #fff;
    border-radius: 6px; font-size: 10px; padding: 1px 4px;
    display: inline-flex; align-items: center; gap: 3px;
}
.permedia-label {
    font-size: 13px; color: var(--secondary-text-color);
}
.permedia-index {
    display: inline-block; min-width: 22px; text-align: center;
    background: #e9eefb; color: #3b5bdb; border-radius: 999px; padding: 2px 6px; margin-right: 6px; font-weight: 600;
}
.permedia-item textarea {
    grid-column: 2 / -1;
    width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box;
}

/* ▼▼ 詳細モーダル：安定レイアウト ▼▼ */
.detail-modal-content {
    display: grid;
    grid-template-rows: minmax(260px, 60%) 1fr;
    background: white;
    width: 90%;
    max-width: 800px;
    height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.modal-overlay.show .detail-modal-content { opacity: 1; transform: scale(1) translateY(0); }

.detail-media-container {
    position: relative;
    min-height: 260px;
    background-color: #000;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; min-width: 0;
}
.carousel-stage { width: 100%; height: 100%; position: relative; }
.carousel-slide { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .25s ease; display: flex; align-items: center; justify-content: center; }
.carousel-slide.active { opacity: 1; pointer-events: auto; }
.carousel-slide img, .carousel-slide video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

.carousel-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: none; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff; cursor: pointer; z-index: 5; display: grid; place-items: center; }
.carousel-nav:hover { background: rgba(0,0,0,0.65); }
.carousel-nav.prev { left: 12px; }
.carousel-nav.next { right: 12px; }

/* ドット（正円） */
.carousel-dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; z-index: 6; }
.carousel-dot {
    width: 8px; height: 8px; aspect-ratio: 1/1;
    border: none; padding: 0; line-height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    display: inline-block; flex: 0 0 auto; cursor: pointer;
    appearance: none; -webkit-appearance: none;
}
.carousel-dot.active { background: rgba(255,255,255,0.95); }

.detail-info-container { padding: 25px 30px; overflow-y: auto; min-height: 0; }
#detail-title { margin-top: 0; margin-bottom: 5px; }
#detail-author { display: block; margin-bottom: 15px; }
#detail-tags { margin-bottom: 25px; line-height: 2; }
.detail-section { margin-bottom: 25px; }
.detail-section h3 { margin: 0; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }

/* コメントは必ず表示されるように */
#detail-comment { display: block; }

/* コピー */
.detail-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.copy-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-color); background: #fff; padding: 6px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, transform .05s ease; }
.copy-btn:hover { background: #f5f5f5; }
.copy-btn:active { transform: translateY(1px); }
.copy-btn.copied { border-color: #46c266; background: #e8f7ed; }
.copy-btn.error { border-color: #e55353; background: #fdeaea; }

.detail-section pre, .detail-section p {
    margin: 10px 0 0 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 15px;
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
}

/* かわいいエフェクト（控えめ） */
.action-btn .burst { position: absolute; left: 50%; top: 50%; pointer-events: none; transform: translate(-50%, -50%); z-index: 2; }
.action-btn .particle { position: absolute; left: 0; top: 0; opacity: 0; transform: translate(-50%, -50%) scale(0.6); animation: burst-pop 700ms ease-out forwards; will-change: transform, opacity; user-select: none; }
@keyframes burst-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(0); }
    40% { opacity: 1; transform: translate(calc(-50% + var(--tx)*.5), calc(-50% + var(--ty)*.5)) scale(1) rotate(var(--rot)); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.8) rotate(var(--rot)); }
}
.action-btn.jelly { animation: jelly-pop 360ms cubic-bezier(.2, .7, .3, 1) both; }
@keyframes jelly-pop { 0%{transform:scale(1);}30%{transform:scale(1.18);}60%{transform:scale(0.95);}100%{transform:scale(1);} }

/* ▼▼ 操作行（削除 & 報告）：右下に内容幅で固定 ▼▼ */
.detail-cta-row{
    position: absolute;
    inset: auto 12px 12px auto;   /* right:12px; bottom:12px と同義 */
    display: flex;
    align-items: center;
    gap: 8px;
    width: max-content;           /* ← 左端まで広がらないように中身の幅に縮める */
    z-index: 10;
}

/* ▼▼ 報告ボタン（デフォは単体右下固定） ▼▼ */
.report-btn{
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1;
    color: var(--secondary-text-color);
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: background-color .15s ease, color .15s ease, transform .05s ease, border-color .15s ease;
}

/* === 削除確認ポップアップ === */
#confirm-overlay.modal-overlay { 
  /* 既存の .modal-overlay と同じ表示制御: .show が付いたら表示、無ければ非表示 */
  display: none;
  background: rgba(10, 12, 20, 0.35);  /* ← 0.35 を上下して暗さ（不透明度）を調整 */
  backdrop-filter: blur(10px);         /* ← 10 を上下してぼかしを調整 */
  -webkit-backdrop-filter: blur(10px);
}
#confirm-overlay.modal-overlay.show {
  display: flex;            /* 中央配置のため flex に */
  align-items: center;
  justify-content: center;
  z-index: 4000;            /* 他より前面に */
}

/* Glassmorphism スタイル（リンクカード準拠） */
.confirm-card {
  position: relative;
  width: 100%;
  max-width: 500px;
  padding: 3rem;
  text-align: center;

  /* ガラス感：透明度とブラー、彩度を強めに */
  background: rgba(30, 28, 45, 0.42);               /* ← 0.42 を上下して透け具合 */
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border: 1px solid rgba(167, 199, 231, 0.22);      /* 枠を少し強調 */
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);         /* 影を少し強めに */

  color: #e9edf5;
   /* 出現は .show 付与時に下の keyframes で制御 */
}

/* A) オーバーレイ自体もスッと現れる（暗幕のフェード） */
#confirm-overlay.modal-overlay.show {
  animation: confirm-overlay-fade .18s ease-out both; /* 既存の z-index:4000 は保持 */
}

/* B) カードのベース状態（非表示時の初期値） */
#confirm-overlay .confirm-card {
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  will-change: opacity, transform;
}

/* C) .show が付いた瞬間に “ふわっと”出現する */
#confirm-overlay.show .confirm-card {
  animation: confirm-float-in .28s cubic-bezier(.2,.7,.3,1) both;
}

/* --- Keyframes（出現）--- */
@keyframes confirm-float-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
    filter: saturate(110%);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(120%);
  }
}

/* --- Keyframes（暗幕）--- */
@keyframes confirm-overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 閉じアニメ（任意） */
#confirm-overlay.closing .confirm-card {
  animation: confirm-float-out .18s ease-in forwards;
}
@keyframes confirm-float-out {
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

/* アニメを減らしたいユーザー配慮 */
@media (prefers-reduced-motion: reduce) {
  #confirm-overlay.modal-overlay.show { animation: none; }
  #confirm-overlay .confirm-card,
  #confirm-overlay.show .confirm-card { animation: none; opacity: 1; transform: none; }
}

.confirm-card h3 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
}
.confirm-card p {
  margin: 0 0 20px;
  line-height: 1.6;
  color: #cdd6e5;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.1);
  color: #e9edf5;
  cursor: pointer;
  transition: transform .05s ease, background-color .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-danger {
  background: rgba(220, 38, 38, 0.9);
  border-color: rgba(220, 38, 38, 0.25);
}
.btn-danger:hover { background: rgba(220, 38, 38, 1); }

.btn-ghost {
  background: rgba(255,255,255,0.08);
  border-color: rgba(167,199,231,0.2);
}
.btn-ghost:hover { background: rgba(255,255,255,0.14); }

/* 操作行（右下コンテナ）に入ったときは絶対配置を解除して横並びに */
.detail-cta-row .report-btn,
.detail-cta-row .delete-btn{
    position: static !important;
    right: auto;
    bottom: auto;
}

.report-btn:hover{ background:#fff; color: var(--text-color); border-color:#dcdcdc; }
.report-btn:active{ transform: translateY(1px); }
.report-btn i{ font-size: 12px; }

/* ▼▼ 削除ボタン ▼▼ */
.delete-btn{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1;
    color: var(--secondary-text-color);
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: background-color .15s ease, color .15s ease, transform .05s ease, border-color .15s ease;
}
.delete-btn:hover{ background:#fff; color: #b00020; border-color:#f1c7c7; }
.delete-btn:active{ transform: translateY(1px); }
.delete-btn i{ font-size: 12px; }

/* --- Responsive Design --- */
@media (max-width: 1024px) {
  .sidebar { position: fixed; transform: translateX(calc(-1 * var(--sidebar-width))); margin-left: 0; }
  .page-wrapper.sidebar-open .sidebar { transform: translateX(0); }
  .header { grid-template-columns: auto 1fr; }
  .header-center { display: none; } /* ] */  /* ← ここを閉じる */
}

/* --- Toast (snackbar) --- */
#toast-container {
  position: fixed;
  left: 50%;
  bottom: 24px; /* 少し下に移動 */
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px; /* 間隔を少し広げる */
  align-items: center;
  pointer-events: none;
  max-width: 90%; /* 幅を制限して中央に */
}

.toast {
  pointer-events: auto;
  color: #f8f8f8; /* リンクカードに合わせて明るいテキスト色に */
  
  /* リンクカードのGlassmorphismスタイルを適用 */
  background: rgba(30, 28, 45, 0.75); /* リンクカードに合わせたダークな背景、少し透明度を上げる */
  backdrop-filter: blur(10px); /* リンクカードに近いぼかし具合 */
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(167, 199, 231, 0.15); /* リンクカードの境界線を適用、少し強調 */
  border-radius: 12px; /* リンクカードより少し小さく、トーストに合う角丸 */
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); /* リンクカードに近い強い影 */

  padding: 14px 22px; /* パディングを増やす */
  font-size: 15px; /* フォントサイズを維持 */
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 12px; /* アイコンとテキストの間隔を広げる */
  animation: toast-in .35s cubic-bezier(.2, .7, .3, 1) forwards; /* アニメーションを微調整 */
  min-width: 240px; /* 最低幅を確保 */
  text-align: center; /* テキストを中央寄せ */
  max-width: 400px; /* トーストの最大幅を設定 */
}

/* 各種メッセージタイプ */
.toast.info {
    color: #f8f8f8;
    /* infoは基本のダークグラスモフィズムを維持 */
}
.toast.success {
    color: #33a433; /* 成功時は明るい緑系のテキスト色 */
    background: rgba(185, 228, 202, 0.952); /* 緑系のダークグラスモフィズム */
    border-color: rgba(144, 238, 144, 0.25); /* 明るい緑の境界線 */
    box-shadow: 0 10px 30px rgba(39, 174, 96, 0.2); /* 緑系の影 */
}
.toast.error {
    color: #ffe6e6; /* エラー時は明るい赤系のテキスト色 */
    background: rgba(231, 76, 60, 0.75); /* 赤系のダークグラスモフィズム */
    border-color: rgba(255, 99, 71, 0.25); /* 明るい赤の境界線 */
    box-shadow: 0 10px 30px rgba(231, 76, 60, 0.2); /* 赤系の影 */
}

/* アイコン（例: Font Awesomeなどを使用する場合） */
.toast .icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0; /* アイコンが縮まないように */
}
.toast.success .icon { color: #82e0aa; } /* 明るい緑のアイコン */
.toast.error .icon { color: #ff8c8c; }   /* 明るい赤のアイコン */
.toast.info .icon { color: #a7c7e7; } /* リンクカード境界線に近い青系のアイコン */


.toast.hide { animation: toast-out .3s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.95); }
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    #toast-container {
        bottom: 16px;
        max-width: calc(100% - 32px); /* 左右に余白 */
    }
    .toast {
        padding: 12px 18px;
        font-size: 14px;
        min-width: unset;
        width: 100%; /* 小画面では幅いっぱいに */
        box-sizing: border-box;
        border-radius: 10px;
    }
}
