/* === Step 1: Windows/Meiryo font metrics override ===
 * WinDescent が大きい Meiryo/游ゴシックで Chromium が
 * 行ボックス外のインク領域をクリップする問題を回避するため、
 * ascent/descent を明示的に上書きした仮想フォントを定義する。
 */
@font-face {
  font-family: 'AdjustedMeiryo';
  src: local('Meiryo UI'), local('Meiryo'), local('Yu Gothic UI'), local('Yu Gothic'), local('MS PGothic');
  ascent-override: 90%;
  descent-override: 40%;
  line-gap-override: 0%;
  font-style: normal;
  font-weight: 100 900;
}

/* Base Variables */
:root {
    /* Light Theme */
    --bg-color: #f0f2f5;
    --card-bg: rgba(255, 255, 255, 0.85);
    --bg-input: #fff;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --accent-color: #3b82f6;
    /* Nice Blue */
    --accent-glow: rgba(255, 183, 197, 0.4);
    --holiday-color: #e07090;
    /* Pastel Red-Pink for holidays/Sun */
    --saturday-color: #7ab0e8;
    /* Pastel Sky Blue for Sat */
    --sunday-color: #e07090;
    /* Pastel Red-Pink for Sun */
    --today-bg: rgba(255, 183, 197, 0.75);
    /* Pastel Pink, semi-transparent */
    --today-text: #5a3040;
    /* Deep pink for readability */
    --today-border-radius: 12px;
    /* Synced with logo roundness */
    --border-radius: 20px;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
    --font-jp: 'Noto Sans JP', sans-serif;
    --font-en: 'Outfit', sans-serif;
    /* Step 1: AdjustedMeiryo を先頭に置き Windows 環境でオーバーライドを優先させる */
    --font-rounded: 'M PLUS Rounded 1c', 'AdjustedMeiryo', 'Noto Sans JP', sans-serif;
    --icon-pink:   #e07090;
    --icon-gold:   #b8860b;
    --icon-red:    #e53e3e;
    --icon-green:  #38a169;
    --icon-yellow: #d69e2e;
    --icon-purple: #805ad5;
    --icon-blue:   #3182ce;

    /* Z-Index Hierarchy */
    --z-base: 1;
    --z-sticky: 100;
    --z-popup: 1000;
    --z-modal: 2000;
    --z-overlay: 3000;
    --z-sheet: 1500;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --card-bg: rgba(30, 41, 59, 0.7);
        --bg-input: #1e293b;
        --text-primary: #f8fafc;
        --text-secondary: #94a3b8;
        --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.2);
        --accent-glow: rgba(255, 130, 165, 0.45);
        /* Pink glow for dark bg */
        --today-bg: rgba(255, 110, 155, 0.92);
        /* Vivid pink for dark mode */
        --today-text: #fff0f5;
        /* Near-white for dark mode */
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: var(--font-en), var(--font-jp);
    background: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(239, 68, 68, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: fit-content;
    min-width: 100%;
    margin: 0 auto;
    /* Allow wide content */
}



/* Calendar Section (Controls + Grid) */
.calendar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    flex: 1;
    min-width: 0;
    position: relative; /* added relative positioning so the floating .controls stay inside */
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    position: relative;
    width: fit-content;
    max-width: 95vw;
    z-index: var(--z-sticky);
    background: transparent; /* 背景・blur は ::before が担当 */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 4px 8px;
    box-shadow: var(--shadow-soft);
    margin: 0 auto;
}

/* backdrop-filter を疑似要素に移動して compositor clip からテキストを分離する。
 * .controls 本体に backdrop-filter があると Chromium がコンポジットレイヤー境界で
 * 子テキストのインク領域をクリップする（Windows 日本語フォント見切れの根本原因）。 */
.controls::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: -1;
}

@media (prefers-color-scheme: dark) {
    .controls {
        background: transparent;
        border: 1px solid rgba(255, 140, 175, 0.18);
    }
    .controls::before {
        background: rgba(30, 41, 59, 0.4);
    }
}

.nav-btn {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.nav-btn:hover {
    transform: translateY(-2px);
    color: var(--accent-color);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

/* Glow Effect for Logo (Pinkish) */
.logo-btn:hover {
    color: #ff85a2;
    filter: drop-shadow(0 0 12px rgba(255, 133, 162, 0.6));
}

.nav-btn:active {
    transform: translateY(0) scale(0.95);
}

/* Control Groups & Separators */
.control-group {
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 4px;
}

.control-separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

@media (prefers-color-scheme: dark) {
    .control-separator {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Toggle Months Button */
.toggle-months-btn {
    border-radius: 12px;
    width: auto;
    padding: 0 4px;
    gap: 2px;
}



.current-date-display {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Noto Sans JP', sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 6px 16px;
    border-radius: 999px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.current-date-display:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Layout */
.main-layout {
    display: flex;
    gap: 24px;
    align-items: center;
    /* Center horizontally in column mode */
    /* justify-content: center; REMOVED to prevent top clipping in vertical mode */
    width: 100%;
    flex: 1;
    min-height: 0;
    /* Viewport height minus body padding */
    padding-bottom: 20px;
    /* Ensure bottom scroll clearance */
    overflow-y: visible;
    overflow-x: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-layout.pos-top {
    flex-direction: column;
}

/* Adjust Vertical Flow for Top Layout */
.main-layout.pos-top .media-area {
    order: 1;
    margin-top: 0;
}

.main-layout.pos-top .layout-splitter {
    order: 2;
}

.main-layout.pos-top .calendar-section {
    order: 3;
    margin-bottom: 0;
}

.main-layout.pos-bottom {
    flex-direction: column;
}

/* Adjust Vertical Flow for Bottom Layout */
.main-layout.pos-bottom .calendar-section {
    margin-top: 0;
}

.main-layout.pos-bottom .media-area {
    margin-bottom: 0;
}

.main-layout.pos-left {
    flex-direction: row-reverse;
    justify-content: center;
    align-items: center;
}

.main-layout.pos-right {
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

/* Ensure sticky works correctly when vertical */
.main-layout.pos-top .media-area,
.main-layout.pos-bottom .media-area {
    position: static;
    /* width is managed by JS (adjustMediaLayout) */
    flex: 0 0 auto;
    /* Prevent unwanted growing */
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Center the container content */
    overflow: hidden;
    margin-left: auto;
    margin-right: auto;
}

/* --- Splitter (Resizer) Styles --- */
.layout-splitter {
    background: transparent;
    position: relative;
    z-index: var(--z-sticky);
    transition: background 0.2s;
    /* Default visibility (hidden for some layouts if not needed, but generally cross-axis flex) */
    display: flex;
    align-items: center;
    justify-content: center;
}

.layout-splitter::after {
    content: '';
    position: absolute;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    transition: background 0.2s, transform 0.2s;
}

.layout-splitter:hover::after,
.layout-splitter.is-resizing::after {
    background: var(--accent-color);
}

/* Horizontal Splitter (for pos-top/pos-bottom layout) */
.main-layout.pos-top .layout-splitter,
.main-layout.pos-bottom .layout-splitter {
    width: 100%;
    height: 12px;
    cursor: row-resize;
    margin: 4px 0;
}

.main-layout.pos-top .layout-splitter::after,
.main-layout.pos-bottom .layout-splitter::after {
    width: 40px;
    height: 4px;
}

.main-layout.pos-top .layout-splitter:hover::after,
.main-layout.pos-bottom .layout-splitter.is-resizing::after {
    transform: scaleY(1.5);
}

/* Vertical Splitter (for pos-left/pos-right layout) */
.main-layout.pos-left .layout-splitter,
.main-layout.pos-right .layout-splitter {
    width: 12px;
    height: 100%;
    cursor: col-resize;
    margin: 0 4px;
}

.main-layout.pos-left .layout-splitter::after,
.main-layout.pos-right .layout-splitter::after {
    width: 4px;
    height: 40px;
}

.main-layout.pos-left .layout-splitter:hover::after,
.main-layout.pos-right .layout-splitter.is-resizing::after {
    transform: scaleX(1.5);
}

/* Disable transitions during resize for smooth dragging */
.main-layout.is-resizing * {
    transition: none !important;
    user-select: none;
}

/* Calendar Layout */
.calendar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: fit-content;
    flex: 0 0 auto;
    position: relative;
    /* Don't shrink/grow */
    /* Prevent growing to fill space */
}

.calendar-wrapper {
    display: flex;
    gap: 24px;
    justify-content: center;
    /* Removed flex: 1 to allow content-based centering in main-layout */
    /* Default to row but wrapping allowed for responsiveness */
    flex-wrap: wrap;
    min-width: 0;
}

/* Media Area */
.media-area {
    width: 550px;
    /* Matches default calendar width */
    flex-shrink: 0;
    position: sticky;
    top: 20px;
}

/* For side layouts, ensure height is managed */
.main-layout.pos-left .media-area,
.main-layout.pos-right .media-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.media-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-soft);
    border-radius: var(--border-radius);
    padding: 12px;
    width: 100%;
    height: 100%;
    min-height: 200px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* overflow: hidden を削除してメニューの飛び出しを許可 */
    position: relative;
}

.media-controls-wrapper {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: var(--z-sticky);
    opacity: 0.1; /* 通常時はステルス（薄く表示） */
    transition: opacity 0.3s ease;
    pointer-events: none; /* 下の要素の操作を邪魔しない */
}

.media-container:hover .media-controls-wrapper {
    opacity: 1;
}

.media-controls-wrapper > * {
    pointer-events: auto; /* 子要素はクリック可能に */
}

.media-content-layer {
    flex: 1;
    width: 100%;
    min-height: 0;
    /* Allow shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* For absolutely positioned nav buttons */
}

/* Quick Media Mode Controls */
.quick-media-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

@media (prefers-color-scheme: dark) {
    .quick-media-controls {
        background: rgba(30, 41, 59, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

.global-paste-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0.7;
}

.global-paste-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.media-mode-wrapper {
    position: relative;
    display: flex;
}


/* Layout Mode Controls */
.layout-mode-wrapper {
    position: relative;
    display: flex;
}

.layout-dropdown {
    position: fixed;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 6px;
    min-width: 120px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.layout-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.layout-item {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.layout-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.layout-item.is-active {
    background: var(--accent-color);
    color: white;
}

.layout-mode-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0.7;
}

.layout-mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.layout-mode-btn.active {
    background: var(--accent-color);
    color: white;
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    .layout-dropdown {
        background: rgba(30, 41, 59, 0.85);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .layout-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

.interval-dropdown {
    position: fixed;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 6px;
    min-width: 120px;
    z-index: 10000; /* Ensure it is above any overflow: hidden layers */
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.interval-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.interval-item {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.interval-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.interval-item.is-active {
    background: var(--accent-color);
    color: white;
}

.menu-section-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 4px 12px;
    font-weight: 600;
}

.mode-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.mode-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mode-item.is-active {
    background: var(--accent-color);
    color: white;
}

.interval-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.interval-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
}

.disabled-warning {
    display: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 4px 12px;
    text-align: center;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    margin: 2px 0;
}

.interval-section.disabled {
    pointer-events: none;
}

.interval-section.disabled .interval-grid {
    opacity: 0.3;
}

.interval-section.disabled .disabled-warning {
    display: block !important;
}

.interval-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
    margin: 4px 0;
}

.quick-media-controls:hover {
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.media-mode-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
}

.media-mode-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    opacity: 1;
}

.media-mode-btn.active {
    background: var(--accent-color);
    color: white;
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Quick Search Palette */
.media-search-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    z-index: 20;
    font-size: 1rem;
}

.media-search-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-palette {
    position: absolute;
    top: 50px;
    right: 12px;
    width: 240px;
    max-height: 300px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(12px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.search-palette.hidden {
    display: none;
}

.palette-header {
    padding: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(var(--accent-color-rgb, 59, 130, 246), 0.05);
}

.palette-search-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
    outline: none;
}

.palette-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.9rem;
}

.palette-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.media-content-layer img,
.media-content-layer video {
    object-fit: contain;
}

/* Glassmorphism Layers */
.media-backdrop {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    filter: blur(25px) brightness(0.7);
    z-index: -1;
    opacity: 0.8;
    transform: scale(1.1);
    /* Prevent edge flicker */
}

.media-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
    z-index: 1;
    position: relative;
    transition: transform 0.3s ease;
}

.media-main-img:hover {
    transform: scale(1.02);
}

.media-container.drag-active {
    border: 2px dashed var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

.media-placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.media-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    height: 100%;
    padding: 1rem;
    box-sizing: border-box;
}

.media-empty-state__main {
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
    margin: 0;
}

.media-empty-state__sub {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    opacity: 0.7;
    margin: 0;
}

.calendar-month {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-soft);
    border-radius: var(--border-radius);
    padding: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;

    /* Layout Sizing Consistency */
    flex: 0 0 550px;
    /* Increased to 550px for generous spacing */
    /* FIXED size */
    width: 550px;
    max-width: 550px;
    /* Enforce strict size */
}

.calendar-month:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.month-header {
    text-align: center;
    margin-bottom: 20px;
}

.month-title {
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    font-family: var(--font-rounded);
}

/* Grid System */
.weekday-header,
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}

.weekday-header {
    margin-bottom: 8px;
    column-gap: 2px;
}

.weekday-header span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: var(--font-rounded);
}

.weekday-header .sunday {
    color: var(--sunday-color);
}

.weekday-header .saturday {
    color: var(--saturday-color);
}

.days-grid {
    gap: 2px;
    row-gap: 4px;
}

/* Individual Day Cell */
.day-cell {
    aspect-ratio: 1.3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Events at bottom */
    padding: 0;
    /* Maximize space */
    font-size: 1rem;
    border-radius: 8px;
    cursor: default;
    position: relative;
    transition: background 0.2s;
    min-width: 0;
    overflow: hidden;
}

.day-cell:hover {
    background: rgba(255, 183, 197, 0.08);
}

.day-number {
    font-size: 0.75rem;
    font-weight: 400;
    font-family: var(--font-rounded);
    line-height: 1;
    pointer-events: none;
}

/* Oshi Event Styles */
.oshi-events-container {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    margin-bottom: 2px;
    z-index: 10;
    padding: 0 1px;
}

.oshi-event {
    font-size: 8.5px;
    padding: 0 2px 0 4px;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    line-height: 1.25;
    background: var(--event-bg, #eee);
    color: var(--event-text, #333);
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 12px;
    cursor: help;
}

@keyframes memorial-glow {
    0%   { box-shadow: 0 0 0 0 rgba(255, 220, 80, 0); }
    30%  { box-shadow: 0 0 6px 3px rgba(255, 220, 80, 0.85); }
    70%  { box-shadow: 0 0 6px 3px rgba(255, 220, 80, 0.6); }
    100% { box-shadow: 0 0 0 0 rgba(255, 220, 80, 0); }
}

.oshi-event.is-memorial-active {
    animation: memorial-glow 1.4s ease-out forwards;
}

.oshi-event-icon {
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 0.5px solid rgba(0, 0, 0, 0.1);
}

.oshi-event-svg {
    width: 7px;
    height: 7px;
    stroke-width: 2.0;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.oshi-event-icon.is-dark .icon-gold {
    stroke: #b87300;
}

.oshi-event-icon.is-dark .icon-pink {
    stroke: #c24065;
}

.icon-pink   { stroke: var(--icon-pink); }
.icon-gold   { stroke: var(--icon-gold); }
.icon-red    { stroke: var(--icon-red); }
.icon-green  { stroke: var(--icon-green); }
.icon-yellow { stroke: var(--icon-yellow); }
.icon-purple { stroke: var(--icon-purple); }
.icon-blue   { stroke: var(--icon-blue); }

/* Holiday / Weekend Styling */
.day-cell.is-sunday .day-number,
.day-cell.is-holiday .day-number {
    color: var(--holiday-color);
}

.day-cell.is-saturday .day-number {
    color: var(--saturday-color);
}

.day-cell.is-other-month {
    opacity: 0.3;
}

/* Holiday Name Label - Hover Only */
.holiday-name {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.6rem;
    color: var(--holiday-color);
    margin-top: 0;
    line-height: 1;
    width: auto;
    font-weight: 500;
    white-space: nowrap;
    text-align: right;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.2s;
    background: rgba(255, 255, 255, 0.9);
    /* Background for readability over events */
    padding: 1px 4px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.day-cell:hover .holiday-name {
    opacity: 1;
    /* Show on hover */
    z-index: 20;
}

/* Today Highlight */
.day-cell.is-today {
    background: var(--today-bg) !important;
    border-radius: var(--today-border-radius) !important;
    box-shadow: 0 4px 12px var(--accent-glow);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.day-cell.is-today .day-number,
.day-cell.is-today .holiday-name {
    color: var(--today-text) !important;
}

/* Oshi Date Highlight */
.day-cell.is-oshi-date {
    border: 2px solid var(--oshi-color, var(--accent-color));
    background: rgba(var(--oshi-color-rgb, 59, 130, 246), 0.15) !important;
}

.day-cell.is-oshi-date .day-number {
    font-weight: 700;
    color: var(--oshi-color, var(--accent-color)) !important;
}

/* --- Layout Variations --- */
.calendar-wrapper.direction-column {
    flex-direction: column;
    flex-wrap: nowrap;
    /* Force single column stack */
    align-items: center;
    overflow-y: auto;
}

.calendar-wrapper.direction-row {
    flex-direction: row;
    flex-wrap: nowrap;
    /* Prevent wrapping implies strict horizontal layout */
    overflow-x: auto;
    /* Enable horizontal scroll */
    justify-content: center;
    /* Changed from flex-start to center for better look with 1 or 2 months */
    align-items: flex-start;
    padding-bottom: 20px;
    /* Space for scrollbar */
}

/* --- Targeted Fix: Image Left/Right + Calendar Vertical --- */
/* This prevents calendar top clipping when combining side image position with vertical calendar layout */
.main-layout.pos-left:has(.calendar-wrapper.direction-column),
.main-layout.pos-right:has(.calendar-wrapper.direction-column) {
    align-items: flex-start;
    /* Override default center alignment to prevent top clipping */
}

/* Apply safe centering: centers when space allows, top-aligns when space is insufficient */
.main-layout.pos-left:has(.calendar-wrapper.direction-column) .calendar-section,
.main-layout.pos-left:has(.calendar-wrapper.direction-column) .media-area,
.main-layout.pos-right:has(.calendar-wrapper.direction-column) .calendar-section,
.main-layout.pos-right:has(.calendar-wrapper.direction-column) .media-area {
    margin-top: auto;
    margin-bottom: auto;
}

/* --- Settings Modal --- */
.settings-modal {
    border: none;
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    background: transparent;
    max-width: 720px;
    width: 95%;
}

.settings-modal::backdrop {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

.oshi-manager-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.settings-scroll-area {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 20px;
}

.settings-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.settings-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--accent-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 8px;
}

.settings-form {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.setting-group label {
    font-weight: 500;
    font-size: 0.85rem;
}

.setting-group input[type="text"],
.setting-group input[type="date"],
.setting-group select,
.setting-group textarea {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    font-family: inherit;
    font-size: 0.9rem;
    color: inherit;
}

.setting-group textarea {
    min-height: 80px;
    resize: vertical;
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-chip {
    position: relative;
    display: inline-flex;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    background: #3b82f6;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.2s;
}

.color-chip:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.color-chip input[type="color"] {
    position: absolute;
    inset: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.hex-input {
    flex: 1;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-primary,
.btn-cancel {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-cancel {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.btn-primary:hover,
.btn-cancel:hover {
    opacity: 0.8;
}

.media-area {
    /* Base style for sticky sidebar (left/right) */
    width: 550px;
    max-width: 550px;
    position: sticky;
}

/* Reset width for vertical layouts */
.main-layout.pos-top .media-area,
.main-layout.pos-bottom .media-area {
    width: 100%;
    max-width: none;
}

/* Quick Search Palette */
.media-search-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    z-index: 20;
    font-size: 1rem;
}

/* Media Navigation Buttons */
.media-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    z-index: 20;
    font-size: 1rem;
    opacity: 0;
    /* Hidden by default, shown on hover */
}

.media-container:hover .media-nav-btn {
    opacity: 1;
}

.media-nav-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.media-nav-btn.prev {
    left: 8px;
}

.media-nav-btn.next {
    right: 8px;
}

.media-search-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-palette {
    position: absolute;
    top: 50px;
    right: 12px;
    width: 240px;
    max-height: 300px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(12px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.search-palette.hidden {
    display: none;
}

.palette-header {
    padding: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(var(--accent-color-rgb, 59, 130, 246), 0.05);
}

.palette-search-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
    outline: none;
}

.palette-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.9rem;
}

.palette-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.media-container img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    object-fit: contain;
}

.media-placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.calendar-month {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-soft);
    border-radius: var(--border-radius);
    padding: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;

    /* Layout Sizing Consistency */
    flex: 0 0 550px;
    /* Increased to 550px for generous spacing */
    /* FIXED size */
    width: 550px;
    max-width: 550px;
    /* Enforce strict size */
}

.calendar-month:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.month-header {
    text-align: center;
    margin-bottom: 20px;
}

.month-title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Grid System */
.weekday-header,
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}

.weekday-header {
    margin-bottom: 8px;
    column-gap: 2px;
}

.weekday-header span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.weekday-header .sunday {
    color: var(--sunday-color);
}

.weekday-header .saturday {
    color: var(--saturday-color);
}

.days-grid {
    gap: 2px;
    row-gap: 4px;
}

/* Individual Day Cell */
.day-cell {
    aspect-ratio: 1.3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Events at bottom */
    padding: 0;
    /* Maximize space */
    font-size: 1rem;
    border-radius: 8px;
    cursor: default;
    position: relative;
    transition: background 0.2s;
    min-width: 0;
    overflow: hidden;
}

.day-cell:hover {
    background: rgba(125, 125, 125, 0.05);
}

/* Date Header (Number + Icons) - Absolute to save space */
.day-header {
    position: absolute;
    top: 2px;
    left: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    z-index: 5;
    pointer-events: none;
}

.day-number {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.day-icons {
    display: flex;
    gap: 1px;
}

.day-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.5);
    border: 0.5px solid rgba(0, 0, 0, 0.1);
}

.day-icon-svg {
    width: 7px;
    height: 7px;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Oshi Event Styles */
.oshi-events-container {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    margin-bottom: 1px;
    z-index: 10;
    padding: 0 1px;
}

.oshi-event {
    font-size: 8.5px;
    /* Reduced for better fit */
    padding: 0 1px;
    /* Tighter padding */
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 1px;
    /* Tighter gap */
    line-height: 1.25;
    background: var(--event-bg, #eee);
    color: var(--event-text, #333);
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 12px;
    cursor: help;
    /* Indicate tooltip */
}

/* Holiday / Weekend Styling */
.day-cell.is-sunday .day-number,
.day-cell.is-holiday .day-number {
    color: var(--holiday-color);
}

.day-cell.is-saturday .day-number {
    color: var(--saturday-color);
}

.day-cell.is-other-month {
    opacity: 0.3;
}

/* Holiday Name Label - Hover Only */
.holiday-name {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.6rem;
    color: var(--holiday-color);
    margin-top: 0;
    line-height: 1;
    width: auto;
    font-weight: 500;
    white-space: nowrap;
    text-align: right;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.2s;
    background: rgba(255, 255, 255, 0.9);
    /* Background for readability over events */
    padding: 1px 4px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.day-cell:hover .holiday-name {
    opacity: 1;
    /* Show on hover */
    z-index: 20;
}

/* Today Highlight */
.day-cell.is-today {
    background: var(--today-bg) !important;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.day-cell.is-today .day-number,
.day-cell.is-today .holiday-name {
    color: var(--today-text) !important;
}

/* Oshi Date Highlight */
.day-cell.is-oshi-date {
    border: 2px solid var(--oshi-color, var(--accent-color));
    background: rgba(var(--oshi-color-rgb, 59, 130, 246), 0.15) !important;
}

.day-cell.is-oshi-date .day-number {
    font-weight: 700;
    color: var(--oshi-color, var(--accent-color)) !important;
}

/* --- Layout Variations --- */
.calendar-wrapper.direction-column {
    flex-direction: column;
    flex-wrap: nowrap;
    /* Force single column stack */
    align-items: center;
    overflow-y: auto;
}

.calendar-wrapper.direction-row {
    flex-direction: row;
    flex-wrap: nowrap;
    /* Prevent wrapping implies strict horizontal layout */
    overflow-x: auto;
    /* Enable horizontal scroll */
    justify-content: center;
    /* Changed from flex-start to center for better look with 1 or 2 months */
    align-items: flex-start;
    padding-bottom: 20px;
    /* Space for scrollbar */
}

/* --- Settings Modal --- */
.settings-modal {
    border: none;
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    background: transparent;
    max-width: 720px;
    width: 95%;
}

.settings-modal::backdrop {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

.settings-scroll-area {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 20px;
}

.settings-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.settings-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--accent-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 8px;
}

.settings-form {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.setting-group label {
    font-weight: 500;
    font-size: 0.85rem;
}

.setting-group input[type="text"],
.setting-group input[type="date"],
.setting-group select,
.setting-group textarea {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    font-family: inherit;
    font-size: 0.9rem;
    color: inherit;
}

.setting-group textarea {
    min-height: 80px;
    resize: vertical;
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-chip {
    position: relative;
    display: inline-flex;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    background: #3b82f6;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.2s;
}

.color-chip:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.color-chip input[type="color"] {
    position: absolute;
    inset: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.hex-input {
    flex: 1;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-primary,
.btn-cancel {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-cancel {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.btn-primary:hover,
.btn-cancel:hover {
    opacity: 0.8;
}

.media-area {
    width: 100%;
    max-width: 500px;
    position: static;
}

/* --- Search Palette Tabs --- */
.palette-tabs {
    display: flex;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.palette-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.5);
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
    color: var(--text-secondary);
}

.palette-tab:hover {
    background: rgba(255, 255, 255, 0.8);
}

.palette-tab.active {
    background: #fff;
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

.palette-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.palette-content.active {
    display: flex;
}

/* Register Form Styles */
.register-form {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.register-input-group {
    display: flex;
    gap: 4px;
}

.btn-paste {
    flex-shrink: 0;
    width: 36px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.btn-register-action {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: auto;
    /* Push to bottom */
}

.btn-register-action:hover {
    opacity: 0.9;
}

/* Success Animation */
.success-toast {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    pointer-events: none;
    animation: fadeUp 2s forwards;
    z-index: 100;
    white-space: nowrap;
}

@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    90% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
}

/* --- Local Media Management Styles --- */
.btn-secondary {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .btn-secondary {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.15);
    }
    .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.13);
        border-color: var(--accent-color);
    }
}

.btn-danger-outline {
    background: none;
    border: 1px solid rgba(220, 38, 38, 0.35);
    color: #dc2626;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.btn-danger-outline:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: rgba(220, 38, 38, 0.7);
}

.local-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    margin-top: 8px;
}

.local-image-grid::-webkit-scrollbar {
    width: 5px;
}

.local-image-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

@media (prefers-color-scheme: dark) {
    .local-image-grid {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* 画像サムネイルアイテム */
.local-image-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f0f0f0;
}

@media (prefers-color-scheme: dark) {
    .local-image-item {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

.local-image-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    z-index: 1;
}

.local-img-blur-bg {
    object-fit: cover !important;
    filter: blur(15px);
    opacity: 0.5;
    transform: scale(1.15);
    z-index: 0 !important;
}

.local-image-item .btn-img-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.local-image-item:hover .btn-img-delete {
    opacity: 1;
}

.local-image-item .btn-img-delete:hover {
    background: rgba(239, 68, 68, 0.85);
}

/* タグインジケーター（画像グリッド右下） */
.img-tag-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--accent-color, #3b82f6);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-sizing: border-box;
    box-shadow: 0 0 0 1.5px #fff;
    z-index: 2;
    pointer-events: none;
    line-height: 1;
}

/* Storage Indicator */
.storage-indicator {
    margin-bottom: 8px;
}

.storage-indicator__track {
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 3px;
}

@media (prefers-color-scheme: dark) {
    .storage-indicator__track {
        background: rgba(255, 255, 255, 0.1);
    }
}

.storage-indicator__bar {
    height: 100%;
    background: var(--accent-color, #a78bfa);
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.storage-indicator__footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.storage-indicator__label {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.storage-indicator__count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.storage-indicator__count::before {
    content: '·';
    margin-right: 6px;
    opacity: 0.5;
}

.setting-section-divider {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin: 12px 0;
}

@media (prefers-color-scheme: dark) {
    .setting-section-divider {
        border-top-color: rgba(255, 255, 255, 0.08);
    }
}

/* Compress Setting */
.compress-setting {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
    .compress-setting {
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }
}

.compress-setting__row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 4px;
}

.compress-setting__row .setting-label-sm {
    margin: 0;
    white-space: nowrap;
}

.radio-group--inline {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 0.85rem;
}

.radio-group--inline label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 3px 10px;
    margin-left: auto;
}

/* 画像一覧タグフィルターバー */
.img-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.img-filter-chip {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color, #ddd);
    background: none;
    cursor: pointer;
    color: inherit;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.img-filter-chip:hover {
    border-color: var(--accent-color, #3b82f6);
    color: var(--accent-color, #3b82f6);
}
.img-filter-chip.active {
    background: var(--accent-color, #3b82f6);
    color: #fff;
    border-color: transparent;
}
.img-filter-chip--untagged {
    border-style: dashed;
}
.img-filter-chip--untagged.active {
    background: var(--text-secondary, #888);
    border-style: solid;
}

/* タグバッジ（共通） */
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent-color, #3b82f6) 15%, transparent);
    color: var(--text-primary, #333);
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
    max-width: 120px;
}
.tag-badge .tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    font-size: 13px;
    padding: 0 1px;
    line-height: 1;
    color: inherit;
    flex-shrink: 0;
}
.tag-badge .tag-remove:hover { opacity: 1; }

/* タグ入力エリア */
.tag-input-area {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    min-height: 32px;
    padding: 4px 6px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: var(--bg-input, #fff);
    cursor: text;
}
.tag-input-area input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 12px;
    min-width: 80px;
    flex: 1;
    color: var(--text-primary);
    -webkit-text-fill-color: var(--text-primary);
}

/* タグ履歴サジェスト */
.tag-suggestions-area {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 0.78rem;
}
.suggest-label {
    color: var(--text-secondary, #6b7280);
    font-size: 0.72rem;
}
.suggest-chip {
    padding: 2px 8px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 4px;
    color: var(--accent-color, #3b82f6);
    cursor: pointer;
    font-size: 0.72rem;
    transition: all 0.2s;
}
.suggest-chip:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-color, #3b82f6);
}
@media (prefers-color-scheme: dark) {
    .suggest-chip {
        background: rgba(59, 130, 246, 0.2);
        border-color: rgba(59, 130, 246, 0.3);
    }
}

/* ライトボックス内タグセクション */
.img-lightbox-tags {
    margin-top: 8px;
    padding: 0 4px;
    width: 100%;
    box-sizing: border-box;
}

/* 画像グリッド D&D 並び替え */
.img-drag-handle {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    cursor: grab;
    color: #fff;
    z-index: 2;
}

.local-image-item:hover .img-drag-handle {
    opacity: 1;
}

.img-drag-handle:active {
    cursor: grabbing;
}

.local-image-item.is-img-dragging {
    opacity: 0.35;
}

.local-image-item.drag-over-left {
    box-shadow: -3px 0 0 0 var(--accent-color);
}

.local-image-item.drag-over-right {
    box-shadow: 3px 0 0 0 var(--accent-color);
}

/* 画像ライトボックス（dialog使用でtop layer表示） */
.img-lightbox-dialog {
    border: none;
    background: transparent;
    padding: 0;
    overflow: visible;
    margin: auto;
}

.img-lightbox-dialog::backdrop {
    background: rgba(0, 0, 0, 0.78);
    cursor: zoom-out;
    animation: lb-fade-in 0.15s ease;
}

@keyframes lb-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.img-lightbox-inner {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.img-lightbox-dialog img {
    max-width: 88vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 10px;
    display: block;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.img-lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(30, 30, 30, 0.85);
    color: #fff;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.img-lightbox-close:hover {
    background: #ef4444;
}

.img-lightbox-delete {
    position: absolute;
    top: -14px;
    left: -14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(20, 20, 20, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.img-lightbox-delete:hover {
    background: rgba(239, 68, 68, 0.85);
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

/* Settings Guide (操作ガイド) */
.settings-guide {
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.settings-guide p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* ===== Settings Modal Tabs ===== */
.settings-header {
    padding: 20px 24px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.settings-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 2カラムレイアウト */
.settings-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 左サイドバー */
.settings-sidebar {
    width: 148px;
    flex-shrink: 0;
    padding: 10px 8px;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.settings-sidebar::-webkit-scrollbar { width: 4px; }
.settings-sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.settings-tab-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 9px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.settings-tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.settings-tab-btn.is-active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    font-weight: 600;
}

/* 右コンテンツエリア */
.settings-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.settings-tab-panel {
    display: none;
    padding: 16px 20px;
    max-height: 68vh;
    overflow-y: auto;
    flex: 1;
}

.settings-tab-panel.is-active {
    display: block;
}

.settings-tab-panel::-webkit-scrollbar { width: 5px; }
.settings-tab-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* セクション見出し */
.settings-section-heading {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.setting-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.setting-description {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 4px 0;
    padding: 0 4px;
}

.preview-disclaimer {
    padding: 6px 0;
    margin: 0;
}

.setting-label-sm {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.setting-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 12px 0;
}

/* Media tab */
.media-action-group { margin-bottom: 12px; }

.media-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.btn-media {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-primary);
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.btn-media:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.22);
}

@media (prefers-color-scheme: dark) {
    .btn-media {
        background: rgba(255, 255, 255, 0.07);
        border-color: rgba(255, 255, 255, 0.15);
    }
    .btn-media:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.25);
    }
}

/* Data tab */
.data-btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* Utility Classes */
.ml-auto {
    margin-left: auto;
}
.et-clear-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}
.et-clear-row--desktop {
    justify-content: space-between;
    align-items: center;
}
.et-clear-row--desktop .settings-section-heading {
    margin-bottom: 0;
}

.mobile-oshi-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}
.mobile-oshi-menu-item-danger {
    color: var(--danger-color);
}

.btn-data-action {
    flex: 1;
    min-width: 130px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    text-align: left;
    color: var(--text-primary);
}

.btn-data-action:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--accent-color);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.15);
}

@media (prefers-color-scheme: dark) {
    .btn-data-action {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.12);
    }
    .btn-data-action:hover {
        background: rgba(255, 255, 255, 0.11);
        border-color: var(--accent-color);
    }
}

.btn-data-action svg {
    flex-shrink: 0;
}

.btn-data-action .btn-data-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.btn-data-action span {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
}

.btn-data-action small {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Oshi summary bar in 一般タブ */
.oshi-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.oshi-summary-count {
    font-size: 0.9rem;
}

/* Reset Layout Button */
.btn-reset-layout {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px dashed rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
}

.btn-reset-layout:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

@media (prefers-color-scheme: dark) {
    .settings-guide {
        background: rgba(59, 130, 246, 0.1);
        border-color: rgba(59, 130, 246, 0.2);
    }

    .btn-reset-layout {
        border-color: rgba(255, 255, 255, 0.15);
        background: rgba(255, 255, 255, 0.03);
    }

    .btn-reset-layout:hover {
        border-color: var(--accent-color);
        background: rgba(59, 130, 246, 0.1);
    }
}

/* Details/Summary Styling */
details>summary {
    list-style: none;
    /* Hide default triangle */
}

details>summary::-webkit-details-marker {
    display: none;
}

details>summary::before {
    content: '▶';
    font-size: 0.7rem;
    margin-right: 6px;
    display: inline-block;
    transition: transform 0.2s;
}

details[open]>summary::before {
    transform: rotate(90deg);
}

/* --- Date Hover Popup --- */
#date-hover-popup {
    position: fixed;
    z-index: var(--z-popup);
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 200px;
    max-width: 300px;
    pointer-events: none;
    /* See through clicks */
    display: none;
    animation: fadeIn 0.15s ease-out;
    color: var(--text-primary);
}

.popup-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.popup-date {
    font-size: 1.1rem;
    font-weight: 700;
}

.popup-holiday {
    color: var(--holiday-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.popup-events-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.popup-event-row {
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.03);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #date-hover-popup {
        background: rgba(30, 41, 59, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
    }

    .popup-event-row {
        background: rgba(255, 255, 255, 0.05);
    }

    .popup-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Input styling for manual add */
.manual-add-form {
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-top: 10px;
}


/* Local Image Delete Overlay */
.local-image-item {
    position: relative;
    /* ensure overlay positioning */
}

.local-image-item.is-deleting img {
    opacity: 0.5;
    filter: grayscale(100%);
}

.delete-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: fadeIn 0.1s;
    border-radius: 4px;
    /* Match container */
}

.delete-confirm-text {
    color: #fff;
    font-size: 0.75rem;
    margin-bottom: 4px;
    font-weight: bold;
}

.delete-confirm-actions {
    display: flex;
    gap: 4px;
}

.btn-confirm-delete {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    cursor: pointer;
}

.btn-cancel-delete {
    background: #666;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    cursor: pointer;
}

.interval-row span {
    font-size: 0.9em;
    color: var(--text-primary);
    margin-right: 8px;
    margin-left: 2px;
}

/* Preview Modal Styles */
.preview-modal-content {
    padding: 16px 24px 4px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    padding: 10px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1/1;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Preview: 複数画像モード（ぼかし背景＋contain前面表示）--- */

.preview-grid:not(.is-single) .preview-item img:not(.preview-blur-bg) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.preview-blur-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(15px);
    opacity: 0.5;
    transform: scale(1.15); /* ブラー端の暗化防止 */
}

/* --- Preview: 単体表示モード --- */

.preview-grid.is-single {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.preview-grid.is-single .preview-item {
    width: 100%;
    aspect-ratio: auto;
    border: none;
    background: none;
    border-radius: 0;
}

.preview-grid.is-single .preview-item img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    margin: 0 auto;
    border-radius: 8px;
}

/* Toast Notification */
.toast-container {
    /* Base styles */
    display: none;
    /* Hide by default */
    /* Layout handled in :popover-open */
    pointer-events: none;
    z-index: var(--z-popup);
    border: none;
    background: transparent;
    padding: 0;
    /* Reset UA padding */
    margin: 0;
}

/* Popover positioning - use inset shorthand to override browser defaults */
.toast-container:popover-open {
    /* inset: top right bottom left */
    inset: 24px 0 auto 0 !important;
    position: fixed !important;
    margin: 0 auto !important;
    width: fit-content !important;
    max-width: 90vw !important;

    /* Reset other properties */
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    overflow: visible !important;

    /* Layout */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
}

.toast-message {
    background: rgba(30, 30, 30, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toastFadeIn 0.3s ease forwards;
    opacity: 0;
    pointer-events: auto;
    text-align: center;
    max-width: 90vw;
}

.toast-message.hiding {
    animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* --- Oshi Manager Modal --- */
.oshi-manager-modal {
    max-width: 800px;
    width: 95%;
}

/* ヘッダー内にツールバーを含む */
.oshi-manager-modal .settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
}

/* スクロール可能なテーブル領域 */
.oshi-manager-content {
    padding: 0;
    overflow: hidden;
    max-height: 65vh;
    display: flex;
    flex-direction: column;
}

.oshi-table-header-area {
    flex: 0 0 auto;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.oshi-manager-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 編集モーダルのコンテンツ領域 */
.oshi-edit-content {
    padding: 20px 24px 4px;
    overflow-y: auto;
    max-height: 65vh;
}

.oshi-edit-modal .settings-header {
    padding: 16px 24px 14px;
}

/* 必須マーク */
.required-mark {
    color: #ef4444;
}

.oshi-summary-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.oshi-table {
    width: 100%;
    border-collapse: collapse;
}

.oshi-table thead tr,
.oshi-table tbody tr {
    display: grid;
    grid-template-columns: 48px 44px 1.2fr 1fr 1.5fr 80px;
    align-items: center;
}

/* グループ列あり（1人でもグループ設定済み）の場合は7列レイアウト */
body.oshi-has-group .oshi-table thead tr,
body.oshi-has-group .oshi-table tbody tr {
    grid-template-columns: 48px 44px 1fr 0.8fr 0.9fr 1.3fr 80px;
}

.oshi-table th,
.oshi-table td {
    padding: 10px 8px;
    text-align: left;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oshi-table th {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-top: 12px;
    padding-bottom: 12px;
}

@media (prefers-color-scheme: dark) {
    .oshi-table-header-area {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

.oshi-table td {
    padding-left: 8px;
    padding-right: 8px;
}

.oshi-table tbody tr {
    transition: background 0.15s;
    border-bottom: 1px solid rgba(128, 128, 128, 0.05);
}

.oshi-table tbody tr:hover {
    background: color-mix(in srgb, var(--oshi-color, #3b82f6) 10%, transparent);
}

.oshi-table tbody tr:hover .oshi-handle-cell {
    color: #aaa;
}

.oshi-table tbody tr:hover .btn-icon-delete {
    opacity: 1;
}

.oshi-table tbody tr:hover .btn-icon-edit {
    opacity: 1;
}

.oshi-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--oshi-color, #3b82f6);
}

/* D. ドラッグハンドル列 */
.oshi-th-handle {
    padding-left: 20px !important;
}

.oshi-handle-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    cursor: grab;
    user-select: none;
    padding-left: 20px !important;
}

.oshi-handle-cell:active {
    cursor: grabbing;
}

.oshi-color-cell {
    width: 50px;
    text-align: center;
}

/* ドラッグ中の視覚フィードバック */
.oshi-table tr.is-dragging {
    opacity: 0.4;
}

.oshi-table tr.drag-over-top {
    box-shadow: inset 0 2px 0 0 var(--accent-color, #3b82f6);
}

.oshi-table tr.drag-over-bottom {
    box-shadow: inset 0 -2px 0 0 var(--accent-color, #3b82f6);
}

.oshi-color-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

/* C. 記念日バッジ */
.memorial-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    background: var(--accent-color, #3b82f6);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

/* 次回記念日セル（デスクトップ） */
.oshi-next-date-cell {
    white-space: nowrap;
}

.oshi-next-date-inner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.oshi-table-date-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.75;
}

.oshi-date-more {
    font-size: 0.68rem;
    color: var(--text-secondary);
    opacity: 0.35;
    margin-left: 1px;
}

.oshi-date-cd {
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-left: 3px;
    white-space: nowrap;
}

.oshi-date-cd.is-today    { color: #ef4444; opacity: 1; font-weight: 600; }
.oshi-date-cd.is-tomorrow { color: #f97316; opacity: 1; }
.oshi-date-cd.is-soon     { color: #eab308; opacity: 1; }

/* アクション列 — .oshi-table td (0,1,1) より詳細度を上げる必要がある */
.oshi-table td.oshi-table-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-right: 20px !important;
    overflow: visible;
}

.oshi-th-actions {
    padding-right: 20px !important;
}

/* グループ列: デフォルト非表示（グループ未設定環境） */
.oshi-th-group,
.oshi-group-cell {
    display: none;
}

/* 1人でもグループ設定済みなら列を表示 */
body.oshi-has-group .oshi-th-group,
body.oshi-has-group .oshi-group-cell {
    display: block;
    font-size: 0.82em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* タブレット幅（900px以下）ではグループ列を隠し、6列レイアウトに戻す */
@media (max-width: 900px) {
    body.oshi-has-group .oshi-th-group,
    body.oshi-has-group .oshi-group-cell {
        display: none;
    }
    body.oshi-has-group .oshi-table thead tr,
    body.oshi-has-group .oshi-table tbody tr {
        grid-template-columns: 48px 44px 1.2fr 1fr 1.5fr 80px;
    }
}

.btn-icon-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.btn-icon-delete {
    color: #ef4444;
}

.btn-icon-delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Oshi Manager Toolbar */
.oshi-manager-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.oshi-manager-toolbar .btn-secondary {
    flex: 1;
    justify-content: center;
    white-space: nowrap;
    text-align: center;
}

/* 検索・ソートツールバー（デスクトップ管理モーダル） */
.oshi-table-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding-top: 6px;
}

.oshi-table-search {
    flex: 1;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0 10px;
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
}

.oshi-table-search::placeholder {
    color: var(--text-secondary);
    opacity: 0.55;
}

.oshi-table-search:focus {
    border-color: var(--accent-color);
}

.oshi-table-sort {
    flex-shrink: 0;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0 8px;
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

/* 上部追加ボタン行 */
.oshi-table-add-top-row {
    padding: 8px 16px 2px;
}

/* 検索結果なし行 */
.oshi-table-no-results {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.toolbar-text-link {
    background: none;
    border: none;
    padding: 4px 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.65;
    white-space: nowrap;
    margin-left: auto;
}

.toolbar-text-link:hover {
    opacity: 1;
    color: var(--accent-color);
}

/* Empty State */
.oshi-empty-state {
    padding: 40px 20px;
    text-align: center;
}

.oshi-empty-state__title {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.oshi-empty-state__actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.oshi-empty-state__links {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
}

.oshi-empty-state__sep {
    color: var(--text-secondary);
    opacity: 0.5;
    font-size: 0.8rem;
}

.oshi-empty-state__privacy-badge {
    display: inline-block;
    font-size: 0.78rem;
    color: #2e7d4f;
    background: rgba(46, 125, 79, 0.1);
    border: 1px solid rgba(46, 125, 79, 0.25);
    border-radius: 20px;
    padding: 3px 10px;
    margin: 0 0 12px;
}

.oshi-empty-state__steps {
    display: inline-block;
    text-align: left;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 18px;
    padding-left: 1.4em;
    line-height: 1.8;
}

/* 新規追加フッター（テーブル下部） */
.oshi-add-row {
    padding: 10px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.mobile-oshi-add-row {
    padding: 12px 16px;
}

/* Tag chips in oshi table */
.oshi-tags-cell {
    max-width: 180px;
}

.oshi-tag-chip {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    margin: 1px 2px 1px 0;
    white-space: nowrap;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.oshi-tag-chip--more {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border-color: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    .oshi-table-search,
    .oshi-table-sort {
        background: rgba(255, 255, 255, 0.07);
        border-color: rgba(255, 255, 255, 0.12);
        color-scheme: dark;
    }
    .oshi-manager-modal .settings-form {
        background: rgba(15, 23, 42, 0.88);
    }
}

/* Edit button in action column */
.btn-icon-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.btn-icon-edit:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

/* Oshi Edit Modal */
.oshi-edit-modal {
    max-width: 400px;
}

/* =========================================================
   Day Detail Bottom Sheet (Mobile Only)
   ========================================================= */
.day-detail-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sheet);
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px 20px 0 0;
    padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 70vh;
    overflow-y: auto;
}

.day-detail-sheet.is-open {
    transform: translateY(0);
}

.day-detail-handle {
    width: 36px;
    height: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    margin: 0 auto 12px;
}

.day-detail-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.day-detail-date {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.day-detail-body {
    font-size: 14px;
    color: var(--text-primary);
}

/* 没入モード中（デスクトップ）はシートを非表示 */
body.is-immersive .day-detail-sheet {
    display: none !important;
}

/* Mobile Specific Overrides — body.is-mobile-ui（JS付与: isMobile() = タッチデバイスまたは幅768px以下） */
body.is-mobile-ui {
    padding: 0 !important;
}

body.is-mobile-ui .main-layout {
    flex-direction: column !important;
    height: auto !important;
    overflow-y: visible !important;
}

body.is-mobile-ui .media-area {
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
    order: 1 !important; /* 画像を常に上に固定（仕様 2.1） */
}

body.is-mobile-ui .layout-splitter {
    order: 2 !important;
}

body.is-mobile-ui .calendar-section {
    order: 3 !important; /* カレンダーを常に下に固定 */
}

/* 画像エリアを全画面表示
 * position:fixed で viewport y=0 に固定する理由:
 * Chrome Mobile では body{min-height:100vh} が URL バーを含む大ビューポートで計算され、
 * ドキュメントが実際の viewport より ~92px 長くなる。その結果 .main-layout が
 * viewport の上方にはみ出し画像に黒余白が生じるため、fixed で viewport に直接貼り付ける。
 */
body.is-mobile-ui .media-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 100dvh !important;
    min-height: unset !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #000 !important;
    justify-content: center !important;
}

/* 画像を全幅表示（縦長画像も幅いっぱいに） */
body.is-mobile-ui .media-container img {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100dvh !important;
    height: auto !important;
    border-radius: 0 !important;
    object-fit: contain !important;
}
/* backdrop だけは object-fit:cover を維持（詳細度で上書き） */
body.is-mobile-ui .media-container .media-backdrop {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
}

/* カレンダーセクションはデフォルト非表示 */
body.is-mobile-ui .calendar-section {
    display: none;
    width: 100% !important;
}

body.is-mobile-ui .calendar-wrapper {
    flex-direction: column !important;
    width: 100% !important;
}

body.is-mobile-ui .calendar-month {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
}

/* Hide desktop specific controls */
body.is-mobile-ui .toggle-months-btn,
body.is-mobile-ui #btnToggleLayout,
body.is-mobile-ui .layout-splitter {
    display: none !important;
}

/* モバイルでシートを有効化・z-index修正 */
body.is-mobile-ui .day-detail-sheet {
    display: block;
    z-index: calc(var(--z-modal) + 2); /* 2002: カレンダー・コントロールの上 */
}

/* ---- 2ステートモバイルUI ---- */

/* カレンダーモード: 全画面オーバーレイ */
body.is-mobile-ui .calendar-section.is-expanded {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-color);
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

body.is-mobile-ui .calendar-section.is-expanded .calendar-wrapper {
    padding: 0 10px;
}

/* 画像コントロール: 画像下部に左寄せオーバーレイ（backdrop-filterを避けてabsoluteを使用） */
body.is-mobile-ui .media-controls-wrapper {
    position: absolute !important;
    top: auto !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    left: 12px !important;
    right: auto !important;
    opacity: 0.9 !important;
    pointer-events: auto !important;
    gap: 4px !important;
    justify-content: flex-start !important;
}

/* モバイルでは quick-media-controls は非表示（ボトムバーに統合） */
body.is-mobile-ui .quick-media-controls {
    display: none !important;
}

/* カレンダーセクションにボトムバー＋コントロール分の余白 */
body.is-mobile-ui .calendar-section {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* テロップバーの分だけ展開時のカレンダーを下げる（30px ticker + 8px gap） */
body.is-mobile-ui .calendar-section.is-expanded {
    padding-top: 38px;
}

/* モバイルでは .controls バーをテロップが代替するため非表示 */
body.is-mobile-ui .controls {
    display: none !important;
}

/* ===== カレンダー: Glassmorphism統一カード ===== */

/* ヘッダー + グリッドを単一カードに統合 */
body.is-mobile-ui .calendar-section.is-expanded .calendar-month {
    background: var(--card-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 5px 14px 6px;
}

/* 年月ヘッダー: カード内上部。個別背景なし */
body.is-mobile-ui .month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 4px;
}
body.is-mobile-ui .month-title {
    font-size: 0.9rem;
    font-weight: 700;
}

/* < > ボタン: 文字サイズに合わせた小ぶり配置 */
body.is-mobile-ui .month-nav-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 0;
    flex-shrink: 0;
}
body.is-mobile-ui .month-nav-inline:active { opacity: 0.45; }

/* 曜日ヘッダー */
body.is-mobile-ui .weekday-header {
    margin-bottom: 2px;
}
body.is-mobile-ui .weekday-header span {
    font-size: 0.68rem;
}

/* グリッド: 行高を固定して月移動時のガタつきを完全排除 */
body.is-mobile-ui .days-grid {
    grid-auto-rows: 21px;
}

/* 日付セル: grid-auto-rows に追従 */
body.is-mobile-ui .day-cell {
    aspect-ratio: unset;
    min-height: unset;
    height: 100%;
    overflow: hidden;
}
body.is-mobile-ui .day-number {
    font-size: 0.68rem;
    line-height: 1;
}
/* モバイル: 推しイベントをドット表示に変換（名前テキスト非表示） */
body.is-mobile-ui .oshi-events-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 2px;
    justify-content: center;
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.is-mobile-ui .oshi-event {
    min-height: 0;
    font-size: 0;
    width: 5px;
    height: 5px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.9;
    display: inline-block;
}

/* ドット内アイコンは非表示（日付数字横の day-icon-badge で代替） */
body.is-mobile-ui .oshi-event .oshi-event-icon {
    display: none;
}

/* 5推し目以降は非表示（セル幅オーバーフロー防止） */
body.is-mobile-ui .oshi-event:nth-child(n+5) {
    display: none;
}

/* 日付数字横のアイコンバッジは非表示（ドットのみで表現） */
body.is-mobile-ui .day-icons {
    display: none;
}

/* 祝日名はセル内に収まらないため非表示（シートヘッダーに表示） */
body.is-mobile-ui .holiday-name {
    display: none;
}

/* Day Detail Sheet ではポップアップ用ヘッダーを非表示（シート自体がヘッダーを持つため2重になる） */
body.is-mobile-ui #dayDetailBody .popup-header {
    display: none;
}

/* 旧FABピルを非表示 */
body.is-mobile-ui .mobile-cal-fab {
    display: none !important;
}

/* モバイルでは上/下/左/右/没入はいずれも自動と同等のためすべて非表示 */
body.is-mobile-ui .layout-item[data-layout="top"],
body.is-mobile-ui .layout-item[data-layout="bottom"],
body.is-mobile-ui .layout-item[data-layout="left"],
body.is-mobile-ui .layout-item[data-layout="right"],
body.is-mobile-ui .layout-item[data-layout="immersive"] {
    display: none !important;
}

/* 有効なレイアウト選択肢が自動のみになるためレイアウトボタン自体を非表示 */
body.is-mobile-ui #btnMobileLayout {
    display: none !important;
}

/* 没入モード時: ミニウィジェット(180px)を抑制 */
body.is-mobile-ui.is-immersive .calendar-section {
    display: none !important;
    position: static !important;
    width: auto !important;
}
/* カレンダーモード時は全画面で表示（没入モード上に被せる） */
body.is-mobile-ui.is-immersive .calendar-section.is-expanded {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: calc(var(--z-modal) + 5) !important;
    width: auto !important;
}
/* FABは没入モード中も表示維持 */
body.is-mobile-ui.is-immersive .mobile-cal-fab {
    display: flex !important;
    z-index: calc(var(--z-modal) + 10) !important;
}
/* モバイルでは没入中もデイ詳細シートを有効化（グローバルの display:none を上書き） */
body.is-mobile-ui.is-immersive .day-detail-sheet {
    display: block !important;
}

@media (max-width: 600px) {
    .controls {
        max-width: 100%;
        padding: 6px 12px;
        gap: 4px;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
    }

    .nav-btn i {
        font-size: 14px;
    }

    .current-date-display {
        font-size: 0.9em;
        padding: 4px 8px;
    }
}

/* ランドスケープ（横向き）スマートフォン対応
 * body.is-mobile-ui のセレクタと特定性を揃えるため全ルールに body.is-mobile-ui を付与する。
 * （body.is-mobile-ui は isMobile() = true のとき JS が付与するクラス。
 *   幅 768px 以下の端末は横向きでも isMobile() = true になるため常に適用される。） */
@media (max-height: 500px) and (orientation: landscape) {
    body.is-mobile-ui {
        padding: 0 !important;
    }

    body.is-mobile-ui .main-layout {
        flex-direction: row !important;
        align-items: stretch !important;
        height: 100dvh !important;
        overflow: hidden !important;
        gap: 0 !important;
        padding: 0 !important;
    }

    body.is-mobile-ui .media-area {
        width: 60% !important;
        max-width: 60% !important;
        height: 100dvh !important;
        position: static !important;
        display: block !important;
        flex-shrink: 0;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* スプリッターはランドスケープでは不要 */
    body.is-mobile-ui .layout-splitter {
        display: none !important;
    }

    body.is-mobile-ui .media-container {
        /* body.is-mobile-ui .media-container が position:fixed を設定するため
         * ここで relative にリセットする。
         * relative にすることで .media-backdrop の position:absolute の基準にもなる */
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        height: 100dvh !important;
        padding: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* .media-display-area は JS で display:flex / align-items:center / justify-content:center の
     * インラインスタイルが設定されるため、同じ flex 方向で center 揃えを明示する */
    body.is-mobile-ui .media-display-area {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* .media-backdrop は img 要素だが全体を覆う必要があるため除外 */
    body.is-mobile-ui .media-container img:not(.media-backdrop),
    body.is-mobile-ui .media-main-img {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100dvh !important;
        object-position: center center !important;
        border-radius: 0 !important;
    }

    /* backdrop はコンテナ全体を覆い、z-index:0 で左右両側にぼかし効果を表示する */
    body.is-mobile-ui .media-backdrop {
        width: 100% !important;
        height: 100% !important;
        z-index: 0 !important;
    }

    /* ランドスケープ: カレンダーを非表示にして画像のみ表示 */
    body.is-mobile-ui .calendar-section {
        display: none !important;
    }

    /* ボトムバー・タブパネル・テロップ・ホームバーをすべて非表示 */
    body.is-mobile-ui #mobile-bottom-bar,
    body.is-mobile-ui .ticker-bar {
        display: none !important;
    }
    body.is-mobile-ui .mobile-tab-panel,
    body.is-mobile-ui .mobile-grid-library,
    body.is-mobile-ui .mobile-playback-popover,
    body.is-mobile-ui .mobile-add-submenu {
        display: none !important;
    }

    /* メディアエリアをフル幅に */
    body.is-mobile-ui .media-area {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* コントロールボタンを左上に配置 */
    body.is-mobile-ui .media-controls-wrapper {
        position: absolute !important;
        top: 8px !important;
        bottom: auto !important;
        left: 8px !important;
        right: auto !important;
        opacity: 0.8 !important;
        pointer-events: auto !important;
    }
}


/* --- Immersive Mode --- */
html.is-immersive,
body.is-immersive {
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
}

body.is-immersive .app-container {
    max-width: 100vw !important;
    max-height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.is-immersive .main-layout {
    flex-direction: row !important; /* Force reset */
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    width: 100vw !important;
    height: 100vh !important;
}

body.is-immersive .media-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    z-index: 10;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

body.is-immersive .media-container {
    height: 100vh !important;
    width: 100vw !important;
    border-radius: 0;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

body.is-immersive .media-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    filter: blur(40px) brightness(0.8);
    transform: scale(1.15); /* Prevent blurred edges from leaking empty space */
    z-index: 0;
}

body.is-immersive .media-main-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Main image takes up as much space as possible without cropping */
    position: relative;
    z-index: 1; /* Keep above backdrop */
}

/* Hide normal layout splitter */
body.is-immersive .layout-splitter {
    display: none !important;
}

/* Auto-hide controls in immersive mode */
body.is-immersive .quick-media-controls,
body.is-immersive .calendar-section {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

body.is-immersive.controls-visible .quick-media-controls,
body.is-immersive .quick-media-controls:hover,
body.is-immersive .quick-media-controls:focus-within,
body.is-immersive.controls-visible .calendar-section,
body.is-immersive .calendar-section:hover,
body.is-immersive .calendar-section:focus-within {
    opacity: 1;
    pointer-events: auto;
}

/* Toggle Switch Styling */
.toggle-switch {
    width: 32px;
    height: 18px;
    background: rgba(0,0,0,0.2);
    border-radius: 99px;
    position: relative;
    margin-left: auto;
    transition: background 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.is-active .toggle-switch {
    background: var(--accent-color);
}

.is-active .toggle-switch::after {
    transform: translateX(14px);
}

/* Keep dropdown active background neutral for the toggle item itself */
.layout-item.toggle-immersive.is-active {
    background: transparent;
    color: var(--text-primary);
}

.layout-item.toggle-immersive:hover {
    background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .layout-item.toggle-immersive.is-active {
        color: var(--text-primary);
    }
    .layout-item.toggle-immersive:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    .toggle-switch {
        background: rgba(255,255,255,0.2);
    }
}


/* --- Mini Calendar Widget (Immersive Mode) --- */
body.is-immersive .calendar-section {
    position: fixed;
    z-index: 20;
    bottom: 20px;
    right: 20px;
    width: 180px !important;
    max-width: 90vw;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

@media (prefers-color-scheme: dark) {
    body.is-immersive .calendar-section {
        background: rgba(30, 41, 59, 0.3);
    }
}

body.is-immersive .calendar-section:hover {
    transform: scale(1.02);
}

/* Hide controls in mini widget */
body.is-immersive .controls {
    display: none;
}

body.is-immersive .focus-filter-bar {
    display: none !important;
}

/* Simplify month header */
body.is-immersive .month-header {
    font-size: 1.1rem;
    padding: 4px 0;
    margin-bottom: 8px;
}

/* Prevent fixed sizing from breaking the widget */
body.is-immersive .calendar-month {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    min-width: 0 !important;
}

/* Hide extra months if monthCount > 1 but we are in mini mode */
body.is-immersive .calendar-month:not(:first-child) {
    display: none;
}

body.is-immersive .calendar-wrapper {
    flex-direction: column !important;
    gap: 0;
}

/* Mini grid cells */
body.is-immersive .day-cell {
    min-height: 24px;
    padding: 2px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.is-immersive .day-number {
    font-size: 10px;
    font-weight: 300;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* Redesign "Today" indicator for immersive mode */
body.is-immersive .day-cell.is-today {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

body.is-immersive .day-cell.is-today .day-number {
    font-weight: 700;
    color: var(--primary-color) !important;
}

/* Oshi Date Highlight override for immersive */
body.is-immersive .day-cell.is-oshi-date {
    background: transparent !important;
    border: none !important;
}

/* Indicator dots container placed absolutely at the bottom */
body.is-immersive .oshi-events-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 2px;
    justify-content: center;
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    margin: 0;
}

body.is-immersive .day-icons {
    display: none;
}

body.is-immersive .oshi-event {
    min-height: 0;
    font-size: 0; /* Hide text */
    width: 3px;
    height: 3px;
    padding: 0;
    border-radius: 50%;
    margin: 0;
    opacity: 0.8;
    display: inline-block;
}

body.is-immersive .oshi-event .oshi-event-icon {
    display: none;
}

/* Dragging styles */
body.is-immersive .calendar-section.is-dragging {
    cursor: grabbing;
    opacity: 0.8;
    transform: scale(1.05);
    transition: none; /* Disable transition during drag for smoothness */
}


/* --- Full Overlay (Immersive Mode Click) --- */
body.is-immersive.show-overlay .media-backdrop {
    filter: blur(50px) brightness(0.5); /* Darker blur for overlay */
    z-index: 100;
}

body.is-immersive.show-overlay .calendar-section {
    top: 50% !important;
    left: 50% !important;
    bottom: auto !important;
    right: auto !important;
    transform: translate(-50%, -50%) !important;
    width: calc(550px + 48px) !important;
    max-width: none !important;
    height: auto !important;
    max-height: 90vh !important;
    padding: 24px;
    cursor: default;
    z-index: 101;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable;
}

/* Restore normal calendar look in full overlay */
body.is-immersive.show-overlay .controls {
    display: flex;
    max-width: 550px !important;
}

body.is-immersive.show-overlay .focus-filter-bar {
    display: flex !important;
}

body.is-immersive.show-overlay .calendar-month:not(:first-child) {
    display: block;
}

body.is-immersive.show-overlay .calendar-wrapper {
    display: flex !important;
    gap: 20px !important;
    justify-content: center !important;
    /* オーバーレイパネル自身がスクロールを担うため wrapper のスクロールは無効化 */
    overflow: visible !important;
    padding-bottom: 0 !important;
}

/* ミニウィジェットの flex-direction: column !important を direction-* クラスで上書き */
body.is-immersive.show-overlay .calendar-wrapper.direction-row {
    flex-direction: row !important;
}

body.is-immersive.show-overlay .calendar-wrapper.direction-column {
    flex-direction: column !important;
}

body.is-immersive.show-overlay .oshi-events-container {
    /* ミニウィジェットの絶対配置・横並びドットを標準縦並びに戻す */
    flex-direction: column !important;
    position: static !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    margin: 0 !important;
    margin-bottom: 2px !important;
    gap: 1px !important;
    width: 100% !important;
    padding: 0 1px !important;
}

body.is-immersive.show-overlay .oshi-event {
    /* 標準モードの値に完全一致させる */
    font-size: 8.5px !important;
    width: auto !important;
    height: auto !important;
    padding: 0 2px 0 4px !important;
    border-radius: 2px !important;
    margin: 0 !important;
    opacity: 1 !important;
    display: flex !important;
    min-height: 12px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

body.is-immersive.show-overlay .oshi-event .oshi-event-icon {
    display: flex !important;
}

/* Overlay Background Click Area */
.overlay-dismiss-zone {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99;
    cursor: zoom-out;
}

body.is-immersive.show-overlay .overlay-dismiss-zone {
    display: block;
}

/* 2ヶ月横並び（direction-row）時のみパネル幅を拡張 */
body.is-immersive.show-overlay .calendar-section:has(.calendar-wrapper.direction-row .calendar-month ~ .calendar-month) {
    width: calc(550px * 2 + 20px + 48px + 20px) !important;
}

/* --- Glassmorphism Maintenance --- */
body.is-immersive.show-overlay .calendar-section {
    background: rgba(255, 255, 255, 0.88) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 24px !important;
}

@media (prefers-color-scheme: dark) {
    body.is-immersive.show-overlay .calendar-section {
        background: rgba(30, 41, 59, 0.88) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
    }
}

body.is-immersive.show-overlay .calendar-month {
    /* ミニウィジェットの width:100% !important を標準モードの550pxで上書き */
    flex: 0 0 550px !important;
    width: 550px !important;
    max-width: 550px !important;
    min-width: 550px !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    /* padding は標準モードの 12px をそのまま使用（月カードの視覚的枠として機能） */
}

/* ミニウィジェット上書きを標準モードに戻す */
body.is-immersive.show-overlay .day-cell {
    flex-direction: column !important;
    justify-content: flex-end !important;
    align-items: stretch !important;
    padding: 0 !important;
    min-height: 0 !important;
}

body.is-immersive.show-overlay .day-number {
    font-size: 0.75rem !important;
    font-weight: 400 !important;
    letter-spacing: normal !important;
}

body.is-immersive.show-overlay .day-icons {
    display: flex !important;
}

/* 今日・推し日付のハイライトを標準モードに戻す */
body.is-immersive.show-overlay .day-cell.is-today {
    background: var(--today-bg) !important;
    border-radius: var(--today-border-radius) !important;
    box-shadow: 0 4px 12px var(--accent-glow) !important;
}

body.is-immersive.show-overlay .day-cell.is-today .day-number,
body.is-immersive.show-overlay .day-cell.is-today .holiday-name {
    color: var(--today-text) !important;
}

body.is-immersive.show-overlay .day-cell.is-oshi-date {
    border: 2px solid var(--oshi-color, var(--accent-color)) !important;
    background: rgba(var(--oshi-color-rgb, 59, 130, 246), 0.15) !important;
}

body.is-immersive.show-overlay .day-cell.is-oshi-date .day-number {
    font-weight: 700 !important;
    color: var(--oshi-color, var(--accent-color)) !important;
}

body.is-immersive.show-overlay .calendar-month:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* ── 記念日設定行 ─────────────────────────────────── */
/*
 * モバイル・デスクトップ共通の2段グリッドレイアウト。
 * モーダルが常に狭い（max-width: 400px）ため1段では収まらない。
 * 行1: [icon][type select / type input][del]
 * 行2: [date input (icon+type列 span)][annual]
 */
.memorial-date-row {
    display: grid;
    grid-template-areas:
        "icon type del"
        "date date annual";
    grid-template-columns: auto 1fr auto;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
}

.mdate-type {
    grid-area: type;
    min-width: 0;
    width: 100%;
}

.mdate-date {
    grid-area: date;
    min-width: 0;
    width: 100%;
}

.mdate-annual-label {
    grid-area: annual;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 0.85em;
    color: var(--text-secondary);
    cursor: pointer;
}

.mdate-delete {
    grid-area: del;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 1em;
    line-height: 1;
}

.mdate-delete:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.btn-add-row {
    background: none;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    width: 100%;
    min-height: 44px;
    margin-top: 4px;
    transition: all 0.2s ease;
}

.btn-add-row:hover {
    background: rgba(var(--accent-color-rgb, 59, 130, 246), 0.1);
}

/* ── アイコン選択ボタン ────────────────────────────── */
.mdate-icon-btn {
    grid-area: icon;
    width: 30px;
    height: 30px;
    padding: 0;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mdate-icon-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.mdate-icon-svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* ── アイコンピッカーポップアップ ─────────────────── */
.icon-picker-popup {
    position: fixed;
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    width: 176px; /* 4列: 4×36 + 3×4 + 2×8 = 176px */
}

.icon-picker-popup.is-open {
    display: flex;
}

.icon-chip {
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(0, 0, 0, 0.03);
    border: 1.5px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, border-color 0.1s;
}

.icon-chip:hover {
    background: rgba(0, 0, 0, 0.07);
}

.icon-chip.is-selected {
    border-color: var(--accent-color);
    background: rgba(var(--accent-color-rgb, 59, 130, 246), 0.08);
}

.icon-chip-svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* ── イベントタイプ管理 ───────────────────────────── */
.event-type-manager {
    margin: 12px 0 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: hidden;
}

.event-type-manager > summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.02);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

/* ── モバイル向け記念日行 追加スタイル ──────────────── */
body.is-mobile-ui .oshi-edit-content {
    padding: 16px 16px 4px;
}

body.is-mobile-ui .memorial-date-row {
    gap: 8px 6px;
    background: rgba(0, 0, 0, 0.03);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
}

body.is-mobile-ui .mdate-icon-btn {
    width: 36px;
    height: 36px;
}
body.is-mobile-ui .mdate-delete {
    padding: 8px;
    margin-left: 4px;
}
body.is-mobile-ui .mdate-date {
    font-size: 16px; /* モバイルでのズーム防止 */
}
body.is-mobile-ui .mdate-annual-label {
    justify-content: flex-end;
    padding-left: 8px;
}
body.is-mobile-ui .mdate-annual-icon {
    font-size: 1.1em;
}
body.is-mobile-ui .mdate-type-select {
    font-size: 16px; /* モバイルでのズーム防止 */
}

.event-type-manager > summary::before {
    content: '▶';
    font-size: 0.7em;
    transition: transform 0.15s;
}

.event-type-manager[open] > summary::before {
    transform: rotate(90deg);
}

.event-type-manager > summary::-webkit-details-marker { display: none; }

#eventTypeManagerList {
    padding: 6px 8px;
}

.event-type-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

.et-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
}

.et-rename {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.5;
    font-size: 0.85rem;
    line-height: 1;
}

.et-rename:hover { opacity: 1; }

.et-rename-input {
    font-size: 0.9rem;
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    background: var(--bg-color);
    color: var(--text-primary);
    width: 130px;
}

.et-icon {
    display: flex;
    align-items: center;
}

.et-icon-svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.et-label {
    flex: 1;
    font-size: 0.9em;
}

.et-builtin {
    font-size: 0.75em;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 6px;
    border-radius: 10px;
}

.et-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8em;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
}

.et-delete:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.et-empty {
    font-size: 0.85em;
    color: var(--text-secondary);
    text-align: center;
    padding: 8px;
    margin: 0;
}

/* イベントタイプ追加行（設定タブ） */
.et-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.et-add-icon {
    flex-shrink: 0;
}

.et-name-input {
    flex: 1;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0 10px;
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
}

.et-name-input:focus { border-color: var(--accent-color); }

/* 記念日タイプ select */
.mdate-type-select {
    width: 100%;
    min-width: 0;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

/*
 * .setting-group select { padding: 10px 14px } が詳細度 (0,1,1) で
 * .mdate-type-select { padding: 0 6px } (0,1,0) を上書きする。
 * box-sizing: border-box + height: 32px の状態で縦 padding 10px が効くと
 * 文字描画エリアが 12px になり、フォント (14px超) が縦クリップされる。
 * → 詳細度 (0,2,0) で縦 padding を 0 に戻す。
 */
.memorial-date-row .mdate-type-select {
    padding: 0 10px;
}

body.is-mobile-ui .mdate-type-select {
    flex: none;
    width: 100%;
    font-size: 16px; /* モバイルでのズーム防止 */
}

.mdate-type-new {
    grid-area: type;
    width: 100%;
    min-width: 0;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 0 10px;
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-primary);
    outline: none;
}

.mdate-type-new:focus,
.mdate-type-select:focus { border-color: var(--accent-color); }

@media (prefers-color-scheme: dark) {
    .et-name-input,
    .mdate-type-select,
    .mdate-type-new,
    .et-rename-input {
        background: rgba(255, 255, 255, 0.07);
        border-color: rgba(255, 255, 255, 0.12);
        color-scheme: dark;
    }
}

/* --- Keyboard Focus Styles --- */
:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* --- Version Info --- */
.version-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.version-badge {
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.07);
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--text-secondary);
}

@media (prefers-color-scheme: dark) {
    .version-badge {
        background: rgba(255, 255, 255, 0.1);
    }
}

.version-info .btn-secondary {
    padding: 4px 12px;
    font-size: 0.85rem;
}

.appinfo-howto-list {
    margin: 8px 0 0;
    padding-left: 1.4em;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.9;
}

.appinfo-howto-actions {
    margin-top: 12px;
}

.appinfo-license-list {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.appinfo-license-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.appinfo-license-name {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.appinfo-link {
    font-size: 0.78rem;
    color: var(--color-primary);
    text-decoration: none;
    opacity: 0.85;
}

.appinfo-link:hover {
    text-decoration: underline;
    opacity: 1;
}

.appinfo-link-github {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.appinfo-github-icon {
    flex-shrink: 0;
    opacity: 0.8;
}

/* ========== Mobile Smart Bottom Bar ========== */
/* ===== モバイル5タブバー (デフォルト: 非表示) ===== */
#mobile-bottom-bar.smart-bottom-bar {
    display: none;
}

/* ===== モバイルオーバーレイ要素 (デフォルト: 非表示) ===== */
.mobile-tab-panel,
.mobile-sub-panel {
    display: none;
}

/* ===== テロップバー ===== */
.ticker-bar {
    display: block;
    height: 28px;
    flex: 0 0 auto;
    background: rgba(0, 0, 0, 0.30);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    cursor: default;
}

.ticker-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 12px;
    overflow: hidden;
    white-space: nowrap;
}

.ticker-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.02em;
    white-space: nowrap;
    display: inline-block;
}

.ticker-text.is-scrolling {
    animation: ticker-scroll 22s linear infinite;
    padding-left: 100%;
}

/* フォーカスモードの非表示イベント通知部分 */
.ticker-hidden-events {
    color: rgba(255, 220, 120, 0.92);
}

/* ===== フォーカスフィルターバー ===== */
.focus-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px 4px;
    justify-content: center;
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
}

.focus-chip-badge {
    font-size: 10px;
    vertical-align: middle;
}

body.is-mobile-ui .focus-filter-bar {
    padding: 4px 8px 4px;
    justify-content: flex-start;
}

.filter-expand-btn {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px dashed var(--accent-color, #888);
    background: transparent;
    color: var(--accent-color, #888);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.filter-expand-btn:hover {
    opacity: 1;
}

@keyframes ticker-scroll {
    0%   { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

.mobile-grid-library,
.mobile-playback-popover,
.mobile-add-submenu {
    display: none;
}

/* ===== タブバー本体 ===== */
body.is-mobile-ui #mobile-bottom-bar.smart-bottom-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 0.75fr 1fr 1fr;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 2000;
    background: var(--card-bg, rgba(255, 255, 255, 0.88));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    align-items: flex-end;
    overflow: visible;
}

/* ===== テロップバー ===== */
body.is-mobile-ui .ticker-bar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 200ms ease;
}

/* 管理・設定タブではテロップを非表示（フェードアウト） */
body.is-mobile-ui.mobile-tab-management #tickerBar,
body.is-mobile-ui.mobile-tab-settings   #tickerBar {
    opacity: 0;
    pointer-events: none;
}
/* モバイル固有の上書きはなし（デスクトップ共通スタイルを継承） */

/* オートハイド */
body.is-mobile-ui #mobile-bottom-bar.smart-bottom-bar {
    transition: opacity 0.4s ease, transform 0.4s ease;
}
body.is-mobile-ui #mobile-bottom-bar.is-hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

/* タブボタン共通 */
body.is-mobile-ui .mobile-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--text-secondary, #888);
    cursor: pointer;
    font-size: 10px;
    touch-action: manipulation;
    padding: 8px 4px;
    border-radius: 0;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    height: 64px;
}
body.is-mobile-ui .mobile-tab-btn svg { flex-shrink: 0; }
body.is-mobile-ui .mobile-tab-btn:active { opacity: 0.7; }
body.is-mobile-ui .mobile-tab-btn.is-active { color: var(--accent-color, #ec4899); }

/* 中央の追加ボタン（浮き上がり） */
body.is-mobile-ui .mobile-tab-btn.mobile-tab-add {
    position: relative;
    background: var(--accent-color, #ec4899);
    color: #fff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    padding: 0;
    box-shadow: 0 4px 16px rgba(236, 72, 153, 0.4);
    justify-self: center;
    align-self: center;
    margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 7px);
    flex-direction: row;
    top: -7px;
}
body.is-mobile-ui .mobile-tab-btn.mobile-tab-add span { display: none; }
body.is-mobile-ui .mobile-tab-btn.mobile-tab-add:active { opacity: 0.85; }

/* 追加サブメニュー */
body.is-mobile-ui .mobile-add-submenu {
    display: none;
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg, rgba(255, 255, 255, 0.96));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 8px;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
    z-index: 2100;
}
body.is-mobile-ui .mobile-add-submenu.is-open { display: flex; }
body.is-mobile-ui .mobile-add-submenu button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body.is-mobile-ui .mobile-add-submenu button:active { background: rgba(0, 0, 0, 0.05); }

/* ===== モバイルタブパネル ===== */
body.is-mobile-ui .mobile-tab-panel {
    position: fixed;
    inset: 0;
    z-index: 1800;
    overflow: hidden;
    flex-direction: column;
}
body.is-mobile-ui.mobile-tab-management #mobileManagementPanel { display: flex; }
body.is-mobile-ui.mobile-tab-settings   #mobileSettingsPanel { display: flex; }

/* パネル背景ブラー */
body.is-mobile-ui .mobile-panel-bg-blur {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-color, #f0f4f8);
    filter: blur(25px) brightness(0.8);
    transform: scale(1.1);
    z-index: 0;
}
body.is-mobile-ui .mobile-tab-panel > *:not(.mobile-panel-bg-blur) {
    position: relative;
    z-index: 1;
}

/* 管理パネル内側 */
body.is-mobile-ui .mobile-management-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
body.is-mobile-ui .mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}
body.is-mobile-ui .mobile-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}
body.is-mobile-ui .mobile-header-btn {
    font-size: 13px;
    padding: 6px 14px;
}
/* アクションエリア（追加・検索・ソート） */
body.is-mobile-ui .mobile-oshi-actions {
    flex-shrink: 0;
    display: none; /* JS で flex に切替 */
    flex-direction: column;
    gap: 8px;
    padding: 10px 16px 12px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}
body.is-mobile-ui .mobile-oshi-add-top {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
}
body.is-mobile-ui .mobile-oshi-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
body.is-mobile-ui .mobile-oshi-search {
    flex: 1;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    background: rgba(128, 128, 128, 0.09);
    padding: 0 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
body.is-mobile-ui .mobile-oshi-search::placeholder { color: var(--text-secondary); opacity: 0.55; }
body.is-mobile-ui .mobile-oshi-search:focus { border-color: var(--accent-color); }
body.is-mobile-ui .mobile-oshi-sort {
    flex-shrink: 0;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    background: rgba(128, 128, 128, 0.09);
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 0 6px;
    cursor: pointer;
    outline: none;
    appearance: none;
}

/* 仮想スクロール本体 */
body.is-mobile-ui .mobile-oshi-content-row {
    flex: 1;
    display: none; /* JS で flex に切替 */
    overflow: hidden;
    min-height: 0;
}
body.is-mobile-ui .mobile-oshi-vscroll-area {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    min-width: 0;
}
body.is-mobile-ui .mobile-oshi-vscroll-total {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    pointer-events: none;
}

/* 推しカードリスト（仮想スクロール用） */
body.is-mobile-ui .mobile-oshi-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
body.is-mobile-ui .mobile-oshi-list--virt {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    will-change: transform;
}
body.is-mobile-ui .mobile-oshi-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 6px 0 16px;
    height: 52px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body.is-mobile-ui .mobile-oshi-item:active { background: rgba(128, 128, 128, 0.07); }
body.is-mobile-ui .mobile-oshi-chip {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
body.is-mobile-ui .mobile-oshi-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
body.is-mobile-ui .mobile-oshi-name-col {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
body.is-mobile-ui .mobile-oshi-name {
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.is-mobile-ui .mobile-oshi-group {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.is-mobile-ui .mobile-oshi-tags {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 3px 4px;
    flex-wrap: wrap;
    overflow: hidden;
    max-height: 36px;
    align-content: center;
}
body.is-mobile-ui .mobile-oshi-tag-pill {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 20px;
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0.8;
}
body.is-mobile-ui .mobile-oshi-next-date {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    min-width: 36px;
}
body.is-mobile-ui .m-date-mmdd {
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.75;
}
body.is-mobile-ui .m-date-countdown {
    font-size: 0.6rem;
    color: var(--accent-color);
    opacity: 0.85;
    line-height: 1.2;
}
body.is-mobile-ui .m-date-countdown.is-today { color: #ef4444; opacity: 1; font-weight: 600; }
body.is-mobile-ui .m-date-countdown.is-tomorrow { color: #f97316; opacity: 1; }
body.is-mobile-ui .m-date-countdown.is-soon { color: #eab308; opacity: 1; }
body.is-mobile-ui .mobile-oshi-chevron {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-top: 1.5px solid var(--text-secondary);
    border-right: 1.5px solid var(--text-secondary);
    transform: rotate(45deg);
    opacity: 0.35;
    margin-right: 4px;
}
body.is-mobile-ui .mobile-oshi-no-results {
    list-style: none;
    padding: 40px 16px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* インデックスレール */
body.is-mobile-ui .mobile-oshi-index-rail {
    width: 24px;
    flex-shrink: 0;
    display: none;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0;
}
body.is-mobile-ui .mobile-oshi-index-rail.is-visible { display: flex; }
body.is-mobile-ui .mobile-oshi-index-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 16px;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--accent-color);
    background: none;
    border: none;
    cursor: pointer;
    padding: 1px 0;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
}

/* スクロールバブル */
body.is-mobile-ui .mobile-oshi-scroll-bubble {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.75);
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: rgba(30, 30, 40, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s, transform 0.18s;
    z-index: 2000;
}
body.is-mobile-ui .mobile-oshi-scroll-bubble.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* 空の状態（管理タブ） */
body.is-mobile-ui #mobileOshiEmpty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
}

/* 三点メニューラッパー */
body.is-mobile-ui .mobile-oshi-menu-wrapper {
    position: relative;
}

/* Ghost button — 背景・枠なし */
body.is-mobile-ui .mobile-oshi-menu-btn {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 1.3rem;
    letter-spacing: 0.08em;
    padding: 4px 8px;
    color: var(--text-primary);
    opacity: 0.7;
    transition: opacity 0.15s;
}
body.is-mobile-ui .mobile-oshi-menu-btn:hover,
body.is-mobile-ui .mobile-oshi-menu-btn:active {
    opacity: 1;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* ドロップダウンコンテナ */
body.is-mobile-ui .mobile-oshi-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: rgba(30, 30, 40, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    min-width: 200px;
    z-index: 200;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
}
body.is-mobile-ui .mobile-oshi-menu.is-open { display: block; }
body.is-mobile-ui .mobile-oshi-menu-item {
    display: block;
    width: 100%;
    padding: 15px 18px;
    text-align: left;
    border: none;
    background: none;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body.is-mobile-ui .mobile-oshi-menu-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
body.is-mobile-ui .mobile-oshi-menu-item:active { background: rgba(255, 255, 255, 0.1); }

/* 設定パネル */
body.is-mobile-ui .mobile-settings-inner {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
body.is-mobile-ui .mobile-settings-header {
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    background: inherit;
    backdrop-filter: inherit;
    -webkit-backdrop-filter: inherit;
    z-index: 1;
}
body.is-mobile-ui .mobile-settings-body {
    padding: 16px 20px calc(80px + env(safe-area-inset-bottom, 0px));
}

/* ===== 設定メニューリスト ===== */
body.is-mobile-ui .settings-menu-list {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

body.is-mobile-ui .settings-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.55);
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    border-radius: 12px;
    margin: 2px 0;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
}

body.is-mobile-ui .settings-menu-item:active {
    background: rgba(236, 72, 153, 0.12);
}

body.is-mobile-ui .settings-menu-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

body.is-mobile-ui .settings-menu-label-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

body.is-mobile-ui .settings-menu-label {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.is-mobile-ui .settings-menu-caption {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.is-mobile-ui .settings-menu-chevron {
    color: var(--text-secondary);
    font-size: 1.3rem;
}

/* ===== モバイル設定サブパネル ===== */
body.is-mobile-ui .mobile-sub-panel {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
}

body.is-mobile-ui .mobile-sub-panel.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

body.is-mobile-ui .mobile-sub-panel-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

body.is-mobile-ui .mobile-sub-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: inherit;
    backdrop-filter: inherit;
    -webkit-backdrop-filter: inherit;
    z-index: 1;
}

body.is-mobile-ui .mobile-sub-panel-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    margin: 0;
}

body.is-mobile-ui .mobile-sub-panel-back {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--accent-color, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.6rem;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

body.is-mobile-ui .mobile-sub-panel-back:active {
    background: rgba(236, 72, 153, 0.1);
}

body.is-mobile-ui .mobile-sub-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px calc(80px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
}

/* ===== ホームタブ 固定モードドット ===== */
body.is-mobile-ui .mobile-tab-btn[data-tab="home"] { position: relative; }
body.is-mobile-ui .mobile-home-dot {
    display: none;
    position: absolute;
    top: 9px;
    right: calc(50% - 17px);
    width: 7px;
    height: 7px;
    background: #ec4899;
    border-radius: 50%;
    border: 1.5px solid var(--card-bg, #fff);
}
body.is-mobile-ui .mobile-home-dot.is-visible { display: block; }

/* ===== グリッドライブラリ ===== */
body.is-mobile-ui .mobile-grid-library.is-visible {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    position: fixed;
    inset: 0;
    z-index: 1900;
    background: rgba(0, 0, 0, 0.9);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    align-content: start;
}
body.is-mobile-ui .mobile-grid-thumb {
    aspect-ratio: 1;
    overflow: hidden;
    border: none;
    background: #111;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body.is-mobile-ui .mobile-grid-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
body.is-mobile-ui .mobile-grid-loading,
body.is-mobile-ui .mobile-grid-empty {
    color: #fff;
    text-align: center;
    padding: 40px 20px;
    grid-column: 1 / -1;
    font-size: 14px;
}

/* ===== 再生設定ポップオーバー ===== */
body.is-mobile-ui .mobile-playback-popover.is-visible {
    display: block;
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    background: var(--card-bg, rgba(255, 255, 255, 0.96));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 12px;
    min-width: 180px;
    max-width: 240px;
    z-index: 1900;
}
body.is-mobile-ui .mobile-playback-section { margin-bottom: 4px; }
body.is-mobile-ui .mobile-playback-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
body.is-mobile-ui .mobile-playback-item.is-active { color: var(--accent-color, #ec4899); font-weight: 600; }
body.is-mobile-ui .mobile-playback-item:active { background: rgba(0, 0, 0, 0.05); }
body.is-mobile-ui .mobile-playback-divider { height: 1px; background: rgba(0,0,0,0.08); margin: 8px 0; }
body.is-mobile-ui .mobile-playback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
body.is-mobile-ui .mobile-interval-item {
    padding: 6px 8px;
    border: none;
    background: rgba(0,0,0,0.04);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
body.is-mobile-ui .mobile-interval-item.is-active { background: var(--accent-color, #ec4899); color: #fff; }
body.is-mobile-ui .mobile-interval-item:active { opacity: 0.7; }
body.is-mobile-ui .mobile-interval-item:disabled {
    opacity: 0.32;
    cursor: not-allowed;
    pointer-events: none;
}
body.is-mobile-ui .mobile-playback-section.is-disabled .menu-section-title {
    opacity: 0.45;
}
body.is-mobile-ui .interval-disabled-note {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 6px;
    opacity: 0.8;
}

/* ===== モバイルイベントリスト ===== */
body.is-mobile-ui .mobile-event-list {
    padding: 10px 16px;
    margin-bottom: 24px;
    max-height: 250px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
body.is-mobile-ui .mobile-event-list-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
body.is-mobile-ui .mobile-event-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}
body.is-mobile-ui .mobile-event-date {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 46px;
    padding-top: 4px;
}
body.is-mobile-ui .mobile-event-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
body.is-mobile-ui .mobile-event-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
}
body.is-mobile-ui .mobile-event-name { font-weight: 700; }
body.is-mobile-ui .mobile-event-label { opacity: 0.85; font-size: 12px; }
body.is-mobile-ui .mobile-event-empty {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    padding: 24px 0;
}

@media (prefers-color-scheme: dark) {
    body.is-mobile-ui #mobile-bottom-bar.smart-bottom-bar {
        background: rgba(15, 23, 42, 0.92);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
    }
    body.is-mobile-ui .mobile-tab-btn:active { opacity: 0.6; }
    body.is-mobile-ui .mobile-add-submenu {
        background: rgba(30, 41, 59, 0.96);
        border-color: rgba(255, 255, 255, 0.1);
    }
    body.is-mobile-ui .mobile-add-submenu button { color: var(--text-primary); }
    body.is-mobile-ui .mobile-add-submenu button:active { background: rgba(255, 255, 255, 0.05); }
    body.is-mobile-ui .mobile-management-inner,
    body.is-mobile-ui .mobile-settings-inner {
        background: rgba(15, 23, 42, 0.88);
    }
    body.is-mobile-ui .mobile-panel-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
    body.is-mobile-ui .mobile-oshi-actions { border-bottom-color: rgba(255, 255, 255, 0.08); }
    body.is-mobile-ui .mobile-oshi-search,
    body.is-mobile-ui .mobile-oshi-sort {
        background: rgba(255, 255, 255, 0.07);
        border-color: rgba(255, 255, 255, 0.12);
        color-scheme: dark;
    }
    body.is-mobile-ui .mobile-oshi-item { border-bottom-color: rgba(255, 255, 255, 0.06); }
    body.is-mobile-ui .mobile-oshi-table td { border-bottom-color: rgba(255, 255, 255, 0.06); }
    body.is-mobile-ui .mobile-settings-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
    body.is-mobile-ui .settings-menu-item {
        background: rgba(255, 255, 255, 0.06);
    }
    body.is-mobile-ui .settings-menu-item:active { background: rgba(255, 130, 165, 0.15); }
    body.is-mobile-ui .settings-menu-caption { color: rgba(255, 255, 255, 0.45); }
    body.is-mobile-ui .mobile-sub-panel-inner {
        background: rgba(15, 23, 42, 0.92);
    }
    body.is-mobile-ui .mobile-sub-panel-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
    body.is-mobile-ui .mobile-event-list-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
    body.is-mobile-ui .mobile-playback-popover.is-visible {
        background: rgba(30, 41, 59, 0.96);
        border-color: rgba(255, 255, 255, 0.1);
    }
    body.is-mobile-ui .mobile-playback-item { color: var(--text-primary); }
    body.is-mobile-ui .mobile-playback-divider { background: rgba(255, 255, 255, 0.08); }
    body.is-mobile-ui .mobile-interval-item { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); }
}

/* ========== Import Menu (main UI) ========== */
.import-menu-wrapper .layout-mode-btn {
    color: var(--text-secondary, #666);
}

.import-menu-wrapper .import-dropdown {
    min-width: 200px;
}

/* ========== Full-page Drop Overlay (desktop DnD) ========== */
#page-drop-overlay {
    display: none;
}

#page-drop-overlay:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(59, 130, 246, 0.12);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    border: 3px dashed var(--accent, #3b82f6);
}

.drop-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--accent, #3b82f6);
    font-size: 1.1rem;
    font-weight: 600;
    pointer-events: none;
}

.drop-overlay-inner p {
    margin: 0;
}

/* =========================================================
   Custom Confirm Dialog
   ========================================================= */
.confirm-dialog {
    border: none;
    border-radius: var(--border-radius);
    padding: 0;
    background: transparent;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.confirm-dialog[open] {
    animation: confirmFadeIn 0.22s cubic-bezier(0.34, 1.15, 0.64, 1) both;
}

@keyframes confirmFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-dialog-inner {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    overflow: hidden;
    color: var(--text-primary);
}

.confirm-dialog-body {
    padding: 24px 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.confirm-dialog-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.5;
    margin: 0;
}

.confirm-dialog-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-danger-solid {
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.btn-danger-solid:hover {
    background: #b91c1c;
}

