html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    color: #202124;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#search-overlay a {
    text-decoration: none;
}

#search-overlay a:hover {
    text-decoration: none;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Home */
#home-page {
    text-align: center;
    padding: 80px 20px;
    max-width: 640px;
    margin: 0 auto;
}

.hero-subtitle {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #5f6368;
    margin-bottom: 16px;
}

.hero-search-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 5px;
    font-size: 16px;
    color: #5f6368;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.1);
    transition: all 0.2s;
    text-align: left;
}

.hero-search-btn:hover {
    box-shadow: 0 4px 12px rgba(60, 64, 67, 0.15);
    border-color: #94a3b8;
    color: #202124;
}

.hero-search-btn .fa-search {
    color: #94a3b8;
    font-size: 18px;
}

.hero-search-badge {
    margin-left: auto;
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 12px;
    color: #94a3b8;
}

.hero-search-badge kbd {
    padding: 2px 6px;
    background: #f8f9fa;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

#search-overlay kbd,
#main-content kbd {
    color: gray;
    background-color: #f8fafc;
}

/* Search Overlay */
#search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);

    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#search-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.search-panel {
    width: 100%;
    max-width: 800px;
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 8px 24px rgba(60, 64, 67, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 140px);
    position: relative;

    opacity: 0;
    transform: translateY(-18px) scale(0.97);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#search-overlay.open .search-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.search-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e8eaed;
}

.search-overlay-icon {
    color: #94a3b8;
    font-size: 18px;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #202124;
    background: transparent;
}

#search-input::placeholder {
    color: #94a3b8;
}

#btn-clear,
.btn-close-search {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
}

#btn-clear:hover,
.btn-close-search:hover {
    color: #202124;
}

#btn-clear.hidden {
    display: none;
}

.intent-chips-wrap {
    padding: 12px 20px;
    border-bottom: 1px solid #e8eaed;
    background: #f8f9fa;
    display: none;
}

.intent-chips-wrap.visible {
    display: block;
}

.chips-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 8px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 999px;
    font-size: 14px;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.15s;
}

.chip:hover {
    border-color: #94a3b8;
    color: #94a3b8;
    background: rgba(26, 115, 232, 0.05);
}

.search-body {
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px 0;
}

.section-segment {
    padding: 12px 0;
}

.sec-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0 20px;
    margin-bottom: 8px;
}

.suggestion-group {
    display: flex;
    flex-direction: column;
}

.sug-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #202124;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: inherit;
    font-family: inherit;
}

.sug-item:hover,
.sug-item.active {
    background: #f8f9fa;
}

.sug-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f8f9fa;
    color: #94a3b8;
    flex-shrink: 0;
}

.sug-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.sug-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sug-title {
    font-weight: 500;
    font-size: 15px;
}

.sug-meta {
    font-size: 13px;
    color: #94a3b8;
}

.sug-enter-hint {
    font-size: 12px;
    color: #94a3b8;
    display: none;
    align-items: center;
    gap: 4px;
}

.sug-enter-hint kbd {
    padding: 2px 5px;
    background: #f8f9fa;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
}

.sug-arrow {
    color: #94a3b8;
    font-size: 14px;
    margin-left: 4px;
}

.sug-divider {
    height: 1px;
    background: #e8eaed;
    margin: 4px 20px;
}

.cat-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px;
}

.cat-chip {
    display: inline-flex;
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.15s;
}

.cat-chip:hover {
    background: #94a3b8;
    color: #fff;
    border-color: #94a3b8;
}

.search-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-top: 1px solid #e8eaed;
    background: #f8f9fa;
    font-size: 12px;
    color: #94a3b8;
}

.footer-hint {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-hint kbd {
    padding: 2px 5px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
}

/* AI Toggle */
.footer-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 25px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch label {
    position: absolute;
    inset: 0;
    background: #dadce0;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}

.toggle-switch label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked+label {
    background: #94a3b8;
}

.toggle-switch input:checked+label::after {
    transform: translateX(16px);
}

/* AI Content */
.ai-content {
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.7;
}

.ai-content p {
    margin-bottom: 12px;
}

.ai-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.ai-content a {
    color: #94a3b8;
    text-decoration: underline;
}

.ai-summary-title {
    font-weight: 700;
    color: #202124;
    margin-bottom: 8px;
}

.ai-citations {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e8eaed;
}

.ai-citations-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    color: #5f6368;
}

/* Results Page */
#results-page {
    padding: 0;
}

.results-bar-wrap {
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.results-bar-outer {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
}

.results-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #dadce0;
    border-radius: 5px;
}

.results-bar-inner:focus-within {
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

#results-bar-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
}

#results-bar-clear {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    display: none;
}

#results-bar-clear.visible {
    display: block;
}

.results-body {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.results-meta-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
}

.results-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.results-subtitle {
    font-size: 15px;
    color: #94a3b8;
}

.btn-back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #dadce0;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-back-home:hover {
    background: #e8eaed;
    color: #202124;
}

.results-list-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    display: block;
    padding: 10px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: 5px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.result-card:hover {
    box-shadow: 0 4px 12px rgba(60, 64, 67, 0.15);
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.result-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.result-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #202124;
    line-height: 1.4;
}

.result-card-title mark {
    background: #fef3c7;
    padding: 0 2px;
    border-radius: 2px;
}

.result-badge {
    display: inline-flex;
    padding: 4px 10px;
    background: #f8f9fa;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #5f6368;
    white-space: nowrap;
    flex-shrink: 0;
}

.result-card-snippet {
    font-size: 15px;
    color: #5f6368;
    line-height: 1.6;
}

.result-card-snippet mark {
    background: #fef3c7;
    padding: 0 2px;
}

.no-results-box {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}

.no-results-box i {
    font-size: 40px;
    margin-bottom: 16px;
    display: block;
}

.no-results-box h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: #202124;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #dadce0;
    border-top-color: #94a3b8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@media (max-width: 768px) {
    #search-overlay {
        padding-top: 0;
        align-items: stretch;
    }

    .search-panel {
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        max-height: 100dvh;
    }

    .results-meta-header {
        flex-direction: column;
        gap: 12px;
    }
}

.search-overlay-icon {
    width: 18px;
    text-align: center;
    transition: opacity .15s ease;
}

#results-list a {
    color: #0f172a;
    display: block;
    background-color: #ffffff;
}

#global-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: rgba(255, 255, 255, 0.75);

    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-center {
    text-align: center;
}

.loading-text {
    margin-top: 12px;
    color: #5f6368;
    font-size: 16px;
}

.search-results-hint {
    padding: 10px 20px;
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.search-results-hint strong {
    color: #334155;
    font-weight: 600;
}

.search-results-hint i {
    margin-right: 6px;
    color: #94a3b8;
}

/* widget */
.spw {
    position: fixed;
    right: 0;
    top: 50%;
    z-index: 9999;
    display: flex;
    align-items: center;
    transform: translateY(0);
}

.spw.dragging {
    cursor: grabbing;
}

.spw-pulse {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 58px;
    border-radius: 7px 0 0 7px;
    border: 2px solid #ffdd00;
    opacity: 0;
    pointer-events: none;
    animation: spw-ring 2.2s ease-out 1s 3;
}

@keyframes spw-ring {
    0% {
        opacity: .65;
        transform: translateY(-50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50%) scale(1.18);
    }
}

.spw-tab {
    width: 28px;
    height: 52px;
    background: #fff200;
    border-radius: 7px 0 0 7px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    flex-shrink: 0;
    transition: background .15s, width .15s;
    outline: none;
    position: relative;
    touch-action: none;
    user-select: none;
}

.spw-tab:hover {
    background: #fff200;
    width: 30px;
}

.spw-tab:focus-visible {
    box-shadow: 0 0 0 3px #ffc800cb;
}

.spw-tab svg {
    width: 15px;
    height: 15px;
    stroke: #1f1f1f;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.spw-tooltip {
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%);
    background: #1f1f1f;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 11px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

.spw-tooltip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right: none;
    border-left-color: #1f1f1f;
}

.spw-tab:hover+.spw-tooltip {
    opacity: 1;
}

.spw-kbd {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11.5px;
    font-family: 'Segoe UI', monospace;
    font-weight: 600;
    line-height: 1.6;
}

.spw-plus {
    font-size: 11px;
    opacity: .65;
}