/* --- グローバル検索バー --- */
.global-search-bar {
    position: relative;
    display: none;
    align-items: center;
}

.global-search-bar.show {
    display: flex;
}

.global-search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: #999;
    pointer-events: none;
    z-index: 1;
}

.global-search-bar input {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 36px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    font-family: 'Noto Sans JP', sans-serif;
    color: #333;
    outline: none;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.global-search-bar input::placeholder {
    color: #aaa;
    font-size: 13px;
}

.global-search-bar input:focus {
    border-color: #c9a96e;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.12),
        0 0 0 3px rgba(201, 169, 110, 0.2);
}

.global-search-bar .search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: rgba(0, 0, 0, 0.08);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    color: #888;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.2s;
}

.global-search-bar .search-clear:hover {
    background: rgba(0, 0, 0, 0.15);
}

.global-search-bar .search-clear.show {
    display: flex;
}

.global-search-bar .search-result-badge {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    pointer-events: none;
    display: none;
}

.global-search-bar .search-result-badge.show {
    display: block;
}

/* --- タグ候補ドロップダウン --- */
.search-tag-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
        max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease;
    z-index: 100;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
}

.search-tag-dropdown.show {
    max-height: min(
        480px,
        calc(100dvh - 76px - env(safe-area-inset-top) - env(safe-area-inset-bottom))
    );
    opacity: 1;
    pointer-events: auto;
}

/* --- 検索タブバー --- */
.search-tabs {
    display: flex;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    padding: 0 4px;
}

.search-tab {
    flex: 1;
    padding: 10px 6px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Noto Sans JP', sans-serif;
    color: #999;
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition:
        color 0.2s,
        border-color 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.search-tab:hover {
    color: #666;
}

.search-tab.active {
    color: #333;
    border-bottom-color: #c9a96e;
}

.search-tab .tab-count {
    font-size: 10px;
    font-weight: 600;
    background: rgba(201, 169, 110, 0.15);
    color: #8b6914;
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 18px;
}

.search-tab.active .tab-count {
    background: rgba(201, 169, 110, 0.25);
}

.search-tab .tab-count:empty {
    display: none;
}

/* --- タブコンテンツ --- */
.search-tab-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.search-tab-content::-webkit-scrollbar {
    width: 5px;
}

.search-tab-content::-webkit-scrollbar-track {
    background: transparent;
}

.search-tab-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}

.search-tag-dropdown::-webkit-scrollbar {
    width: 5px;
}

.search-tag-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.search-tag-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}

.search-tag-dropdown-header {
    padding: 12px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1;
}

.search-tag-dropdown-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px 14px;
}

.search-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #e8dcc8;
    background: linear-gradient(135deg, #fdf8ef, #f5ecd8);
    color: #8b6914;
    transition: all 0.2s ease;
    white-space: nowrap;
    animation: chip-in 0.15s ease;
}

.search-tag-chip:hover {
    background: linear-gradient(135deg, #c9a96e, #b8924f);
    color: #fff;
    border-color: #c9a96e;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(201, 169, 110, 0.3);
}

.search-tag-chip:active {
    transform: translateY(0) scale(0.96);
}

.search-tag-chip .tag-count {
    font-size: 10px;
    opacity: 0.65;
    font-weight: 400;
}

.search-tag-dropdown-empty {
    padding: 20px 16px;
    text-align: center;
    color: #bbb;
    font-size: 13px;
}

/* --- 地名検索候補 --- */
.search-place-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.search-place-list {
    padding: 4px 0;
}

.search-place-list::-webkit-scrollbar {
    width: 4px;
}

.search-place-list::-webkit-scrollbar-track {
    background: transparent;
}

.search-place-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.search-place-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 13px;
    color: #333;
}

.search-place-item:hover,
.search-place-item.keyboard-active {
    background: rgba(201, 169, 110, 0.1);
}

.search-place-item:active {
    background: rgba(201, 169, 110, 0.2);
}

.search-place-item .place-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e8f4f8, #d1ecf1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.search-place-item .place-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.search-place-item .place-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-place-item .place-name mark {
    background: rgba(201, 169, 110, 0.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.search-place-loading {
    padding: 12px 16px;
    text-align: center;
    color: #bbb;
    font-size: 12px;
}

.search-place-loading .spinner-small {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #c9a96e;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- もっと見るボタン --- */
.search-load-more {
    display: block;
    width: calc(100% - 24px);
    margin: 6px 12px 10px;
    padding: 8px;
    font-size: 12px;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 500;
    color: #8b6914;
    background: linear-gradient(135deg, #fdf8ef, #f5ecd8);
    border: 1px solid #e8dcc8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.search-load-more:hover {
    background: linear-gradient(135deg, #c9a96e, #b8924f);
    color: #fff;
    border-color: #c9a96e;
}

.search-load-more:active {
    transform: scale(0.97);
}

/* ドロップダウン内セクション区切り */
.search-dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 0;
}

/* --- 浮世絵検索候補 --- */
.search-ukiyoe-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.search-ukiyoe-list {
    padding: 4px 0;
}

.search-ukiyoe-list::-webkit-scrollbar {
    width: 4px;
}

.search-ukiyoe-list::-webkit-scrollbar-track {
    background: transparent;
}

.search-ukiyoe-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.search-ukiyoe-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 13px;
    color: #333;
}

.search-ukiyoe-item:hover,
.search-ukiyoe-item.keyboard-active {
    background: rgba(201, 169, 110, 0.1);
}

.search-ukiyoe-item:active {
    background: rgba(201, 169, 110, 0.2);
}

.search-ukiyoe-item .ukiyoe-thumb {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    background-color: #f0ebe0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.search-ukiyoe-item .place-name mark {
    background: rgba(201, 169, 110, 0.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* モバイルレイアウト: タイトルの下に検索バー */
@media (max-width: 600px) {
    .header-bar {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .drawer-toggle {
        max-width: 100%;
    }

    .drawer-toggle .app-name {
        max-width: calc(100vw - 104px - env(safe-area-inset-left) - env(safe-area-inset-right));
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .global-search-bar.show {
        flex: 0 0 auto;
        max-width: 100%;
    }

    .search-tag-dropdown.show {
        max-height: none;
    }

    .search-tab {
        min-height: 44px;
        padding: 8px 4px 6px;
        font-size: 11px;
    }

    .search-tab-content {
        max-height: 250px;
    }

    .search-load-more {
        padding: 10px;
        font-size: 13px;
    }
}
