:root {
    --primary: #3a7ae8;
    --secondary: #2563eb;
    --page-bg: #eef4ff;
    --surface: #ffffff;
    --text-main: #1e3a8a;
    --text-muted: #475569;
    --text-dim: #64748b;
    --border-soft: #dbe4f0;
    --header-text: #1e3a8a;
    --on-primary: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #60a5fa;
        --secondary: #3b82f6;
        --page-bg: #0f172a;
        --surface: #1e293b;
        --text-main: #93c5fd;
        --text-muted: #cbd5e1;
        --text-dim: #94a3b8;
        --border-soft: #334155;
        --header-text: #dbeafe;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--page-bg);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-main);
}

.container { max-width: 960px; margin: 0 auto; }

.header { text-align: center; margin: 48px 0 28px; }
.header h1 { font-size: 2.4em; margin-bottom: 8px; color: var(--header-text); }
.header p { font-size: 1em; color: var(--text-muted); }

.search-area { position: relative; max-width: 760px; margin: 0 auto; }

.search-box {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 8px 8px 8px 20px;
    display: flex;
    box-shadow: 0 4px 20px rgba(58,122,232,.12);
    margin-bottom: 14px;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.1em;
    padding: 10px;
    min-width: 0;
    color: var(--text-main);
    background: transparent;
}

.search-box input::placeholder { color: var(--text-dim); }

.search-box button {
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    padding: 10px 30px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background .3s;
}

.search-box button:hover { background: var(--secondary); }

.home-panels { max-width: 760px; margin: 22px auto 0; }
.home-panel { margin-bottom: 18px; }
.home-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.home-panel-title { font-size: .85em; color: var(--text-dim); margin: 0; }
.clear-history {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: .8em;
    cursor: pointer;
    padding: 2px 4px;
}
.clear-history:hover { color: var(--primary); }
.clear-history:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

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

.hot-chip, .history-chip {
    border-radius: 999px;
    padding: 7px 16px;
    font-size: .9em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform .15s, box-shadow .15s;
}

.hot-chip { background: var(--surface); color: var(--primary); border-color: var(--border-soft); }
.hot-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(58,122,232,.15); }
.history-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-soft);
}
.history-chip:hover { border-color: var(--primary); color: var(--primary); }
.history-chip-del {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    padding: 0 1px;
}
.history-chip-del:hover { color: #dc2626; }
.history-chip-del:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-radius: 3px; }

.suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 62px;
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(30,58,138,.12);
    overflow: hidden;
    display: none;
    color: var(--text-main);
}

.suggestions.open { display: block; }

.suggestion-item {
    padding: 10px 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-soft);
    font-size: 14px;
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.active { background: #eef4ff; }

.type-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }

.type-tabs button {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
}

.type-tabs button:hover { border-color: var(--primary); color: var(--primary); }
.type-tabs button.active { background: var(--primary); color: var(--on-primary); font-weight: 500; border-color: var(--primary); }

.type-tabs button:focus-visible,
.search-box button:focus-visible,
.suggestion-item:focus-visible,
.copy-btn:focus-visible {
    outline: 3px solid #fde68a;
    outline-offset: 2px;
}

.search-info { color: var(--text-muted); margin-bottom: 20px; font-size: .9em; min-height: 22px; text-align: center; }

.loading { display: none; margin-top: 20px; }
.loading-caption { text-align: center; color: var(--primary); font-size: .92em; margin-top: 16px; }

.skeleton-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 10px;
}
.sk-line {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--border-soft) 25%, var(--page-bg) 50%, var(--border-soft) 75%);
    background-size: 200% 100%;
    animation: sk-shimmer 1.4s ease-in-out infinite;
    margin-bottom: 10px;
}
.sk-line:last-child { margin-bottom: 0; }
.sk-title { width: 62%; height: 15px; }
.sk-title.short { width: 42%; }
.sk-meta { width: 30%; height: 10px; }
.sk-text { width: 88%; }
.sk-text.short { width: 55%; }
@keyframes sk-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.results { display: none; }

.result-item {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(30,58,138,.05);
    transition: border-color .2s, box-shadow .2s;
    content-visibility: auto;
    contain-intrinsic-size: auto 120px;
}

.result-item:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(58,122,232,.1); }

.result-body { min-width: 0; }

.result-heading { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 7px; }

.disk-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--disk-color, var(--primary));
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .68em;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
}

.result-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.tag {
    font-size: .72em;
    font-weight: 500;
    line-height: 1.5;
    padding: 1px 7px;
    border-radius: 5px;
    white-space: nowrap;
}
.tag-top { background: #fef3c7; color: #b45309; }
.tag-source { background: #dbeafe; color: #1d4ed8; }
.tag-ok { background: #ccfbf1; color: #0f766e; }
.tag-dead { background: #fee2e2; color: #b91c1c; }
.tag-unknown { background: #f1f5f9; color: #64748b; }
.tag-community,
.tag-time { background: transparent; color: var(--text-dim); padding-left: 0; padding-right: 0; }

@media (prefers-color-scheme: dark) {
    .tag-top { background: #78350f; color: #fde68a; }
    .tag-source { background: #1e3a8a; color: #bfdbfe; }
    .tag-ok { background: #134e4a; color: #5eead4; }
    .tag-dead { background: #7f1d1d; color: #fecaca; }
    .tag-unknown { background: #1e293b; color: #94a3b8; }
}

.result-item.result-dead { opacity: 0.6; }
.result-item.result-dead .result-title { text-decoration: line-through; color: var(--text-dim); }

.copy-btn {
    border: 1px solid #16a34a;
    background: #f0fdf4;
    color: #15803d;
    border-radius: 8px;
    padding: 3px 9px;
    font-size: 12px;
    cursor: pointer;
}

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 12px;
}

.get-btn,
.link-btn {
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.get-btn {
    background: var(--primary);
    color: #ffffff;
    border: 1px solid var(--primary);
}

.get-btn:hover { background: var(--secondary); border-color: var(--secondary); }

.link-btn {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-soft);
}

.link-btn:hover { border-color: var(--primary); }

.get-btn:focus-visible,
.link-btn:focus-visible {
    outline: 3px solid #fde68a;
    outline-offset: 2px;
}

.result-title {
    flex: 1;
    min-width: 0;
    font-size: 1.08em;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
}

.result-title:hover { text-decoration: underline; }
.result-snippet { color: var(--text-muted); line-height: 1.55; font-size: .88em; margin-top: 4px; }

.no-results {
    background: var(--surface);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-dim);
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
}

.no-results h2 { font-size: 1.3em; margin-bottom: 8px; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #ffffff;
    color: #1f2937;
    padding: 10px 16px;
    z-index: 100;
    border-radius: 8px;
}

.skip-link:focus { left: 12px; top: 12px; }

@media (max-width: 768px) {
    .header { margin-top: 40px; }
    .header h1 { font-size: 2.1em; }
    .search-box button { padding: 10px 18px; }
    .result-item { padding: 13px 14px; }
    .result-title { font-size: 1em; }
    .result-heading { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
