:root {
    --bg: #fff;
    --surface: #fff;
    --border: #dfe1e5;
    --text: #202124;
    --text-soft: #70757a;
    --primary: #1a73e8;
    --bar-bg: rgba(255,255,255,0.96);
    --hover: #f1f3f4;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #202124;
    --surface: #303134;
    --border: #3c4043;
    --text: #e8eaed;
    --text-soft: #9aa0a6;
    --primary: #8ab4f8;
    --bar-bg: rgba(32,33,36,0.96);
    --hover: #3c4043;
    color-scheme: dark;
}

*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;padding:0;min-height:100%}

body {
    background: var(--bg);
    color: var(--text);
    font-family: arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a{color:inherit}
button,input,textarea{font:inherit}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.sr-only {
    position:absolute;width:1px;height:1px;
    margin:-1px;padding:0;border:0;
    clip:rect(0,0,0,0);overflow:hidden;
}

/* ── Top bar ────────────────────── */

.top-bar {
    position: fixed;
    top: max(6px, env(safe-area-inset-top));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 50;
    height: 36px;
    width: max-content;
    max-width: calc(100% - 12px);
    background: var(--bar-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.top-bar-inner {
    max-width: calc(100vw - 22px);
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 6px;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
}

.top-bar-inner::-webkit-scrollbar{display:none}

.top-chip {
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    -webkit-appearance: none;
    appearance: none;
    height: 28px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    font-size: 0;
    cursor: default;
}

.top-chip:hover { background: var(--hover); border-radius: 999px; }

.top-chip-link { text-decoration: none; cursor: pointer; }
.top-chip-icon { width: 28px; justify-content: center; padding: 0; cursor: pointer; }
.top-icon { font-size: 13px; line-height: 1; }
.top-value { font-size: 11px; font-weight: 400; color: var(--text-soft); }
.theme-toggle-btn { cursor: pointer; border: none; background: transparent; }

.top-bar-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ── Main app ───────────────────── */

.app {
    width: min(582px, calc(100% - 2rem));
    margin: 0 auto;
    padding: calc(44px + max(18vh, 80px)) 0 2.5rem;
    text-align: center;
}

/* ── Animated Logo ──────────────── */

.logo {
    display: block;
    position: relative;
    text-decoration: none;
    line-height: 1;
    margin-bottom: 18px;
    isolation: isolate;
    transition: transform 0.35s ease;
}

.logo:hover { transform: scale(1.02); }

.logo-net {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 115%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 0;
    color: var(--primary);
}

.net-edges line {
    stroke: currentColor;
    stroke-width: 0.7;
    stroke-opacity: 0.15;
    stroke-dasharray: 300;
    animation: edgeDraw 1.6s ease both, edgePulse 5s ease-in-out infinite;
}

.net-edges line:nth-child(1)  { animation-delay: 0.50s, 3.00s; }
.net-edges line:nth-child(2)  { animation-delay: 0.56s, 3.15s; }
.net-edges line:nth-child(3)  { animation-delay: 0.62s, 3.30s; }
.net-edges line:nth-child(4)  { animation-delay: 0.68s, 3.45s; }
.net-edges line:nth-child(5)  { animation-delay: 0.74s, 3.60s; }
.net-edges line:nth-child(6)  { animation-delay: 0.80s, 3.75s; }
.net-edges line:nth-child(7)  { animation-delay: 0.86s, 3.90s; }
.net-edges line:nth-child(8)  { animation-delay: 0.92s, 4.05s; }
.net-edges line:nth-child(9)  { animation-delay: 0.98s, 4.20s; }
.net-edges line:nth-child(10) { animation-delay: 1.04s, 4.35s; }
.net-edges line:nth-child(11) { animation-delay: 1.10s, 4.50s; }
.net-edges line:nth-child(12) { animation-delay: 1.16s, 4.65s; }
.net-edges line:nth-child(13) { animation-delay: 1.22s, 4.80s; }
.net-edges line:nth-child(14) { animation-delay: 1.28s, 4.95s; }
.net-edges line:nth-child(15) { animation-delay: 1.34s, 5.10s; }
.net-edges line:nth-child(16) { animation-delay: 1.40s, 5.25s; }
.net-edges line:nth-child(17) { animation-delay: 1.46s, 5.40s; }
.net-edges line:nth-child(18) { animation-delay: 1.52s, 5.55s; }
.net-edges line:nth-child(19) { animation-delay: 1.58s, 5.70s; }
.net-edges line:nth-child(20) { animation-delay: 1.64s, 5.85s; }
.net-edges line:nth-child(21) { animation-delay: 1.70s, 6.00s; }
.net-edges line:nth-child(22) { animation-delay: 1.76s, 6.15s; }
.net-edges line:nth-child(23) { animation-delay: 1.82s, 6.30s; }
.net-edges line:nth-child(24) { animation-delay: 1.88s, 6.45s; }
.net-edges line:nth-child(25) { animation-delay: 1.94s, 6.60s; }

.net-nodes circle {
    fill: currentColor;
    opacity: 0.5;
    transform-origin: center;
    transform-box: fill-box;
    animation: nodeScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both, nodePulse 3.5s ease-in-out infinite;
}

.net-nodes circle:nth-child(1)  { animation-delay: 0.70s, 2.50s; }
.net-nodes circle:nth-child(2)  { animation-delay: 0.75s, 2.70s; }
.net-nodes circle:nth-child(3)  { animation-delay: 0.80s, 2.90s; }
.net-nodes circle:nth-child(4)  { animation-delay: 0.85s, 3.10s; }
.net-nodes circle:nth-child(5)  { animation-delay: 0.90s, 3.30s; }
.net-nodes circle:nth-child(6)  { animation-delay: 0.95s, 3.50s; }
.net-nodes circle:nth-child(7)  { animation-delay: 1.00s, 3.70s; }
.net-nodes circle:nth-child(8)  { animation-delay: 1.05s, 3.90s; }
.net-nodes circle:nth-child(9)  { animation-delay: 1.10s, 4.10s; }
.net-nodes circle:nth-child(10) { animation-delay: 1.15s, 4.30s; }
.net-nodes circle:nth-child(11) { animation-delay: 1.20s, 4.50s; }
.net-nodes circle:nth-child(12) { animation-delay: 1.25s, 4.70s; }
.net-nodes circle:nth-child(13) { animation-delay: 1.30s, 4.90s; }
.net-nodes circle:nth-child(14) { animation-delay: 1.35s, 5.10s; }
.net-nodes circle:nth-child(15) { animation-delay: 1.40s, 5.30s; }
.net-nodes circle:nth-child(16) { animation-delay: 1.45s, 5.50s; }
.net-nodes circle:nth-child(17) { animation-delay: 1.50s, 5.70s; }

.logo-glow {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 90px;
    font-weight: 400;
    letter-spacing: -2px;
    font-family: 'Product Sans', arial, sans-serif;
    white-space: nowrap;
    color: var(--primary);
    filter: blur(25px);
    opacity: 0.22;
    animation: glowIn 1.5s ease 0.6s both, glowPulse 5s ease-in-out 2.5s infinite;
    pointer-events: none;
    z-index: 0;
}

.logo-text {
    position: relative;
    z-index: 1;
    display: inline-block;
    font-size: 90px;
    font-weight: 400;
    letter-spacing: -2px;
    font-family: 'Product Sans', arial, sans-serif;
    background: linear-gradient(
        90deg,
        #1a73e8 0%, #4285f4 18%, #6ba3d9 32%,
        #d4a855 48%, #c8956c 58%,
        #6ba3d9 72%, #4285f4 86%, #1a73e8 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradShift 6s ease-in-out infinite;
}

.logo-text > span {
    display: inline-block;
    animation: letterIn 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.logo-text > span:nth-child(1) { animation-delay: 0.15s; }
.logo-text > span:nth-child(2) { animation-delay: 0.22s; }
.logo-text > span:nth-child(3) { animation-delay: 0.29s; }
.logo-text > span:nth-child(4) { animation-delay: 0.36s; }
.logo-text > span:nth-child(5) { animation-delay: 0.43s; }
.logo-text > span:nth-child(6) { animation-delay: 0.50s; }
.logo-text > span:nth-child(7) { animation-delay: 0.57s; }

html[data-theme="dark"] .logo-text {
    background-image: linear-gradient(
        90deg,
        #8ab4f8 0%, #aecbfa 18%, #93c5e8 32%,
        #f0c75e 48%, #e8b931 58%,
        #93c5e8 72%, #aecbfa 86%, #8ab4f8 100%
    );
}

html[data-theme="dark"] .logo-glow { filter: blur(30px); }

@keyframes edgeDraw {
    from { stroke-dashoffset: 300; }
    to { stroke-dashoffset: 0; }
}

@keyframes edgePulse {
    0%, 100% { stroke-opacity: 0.1; }
    50% { stroke-opacity: 0.22; }
}

@keyframes nodeScale {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

@keyframes nodePulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.75; }
}

@keyframes glowIn {
    from { opacity: 0; }
    to { opacity: 0.22; }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.18; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.35; transform: translate(-50%, -50%) scale(1.03); }
}

@keyframes letterIn {
    from { opacity: 0; transform: translateY(28px) scale(0.85); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gradShift {
    0%, 100% { background-position: 0% 0; }
    50% { background-position: 100% 0; }
}

.subtitle {
    margin: 0 auto 24px;
    max-width: 460px;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
}

/* ── Search ──────────────────────── */

.search-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
}

.search-bar {
    position: relative;
    width: 100%;
    max-width: 582px;
}

.search-form input[type="search"] {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    padding: 0 102px 0 20px;
    -webkit-appearance: none;
    appearance: none;
}

.search-form input[type="search"]:hover {
    box-shadow: 0 1px 6px 0 rgba(32,33,36,0.28);
    border-color: rgba(223,225,229,0);
}

.search-form input[type="search"]:focus {
    box-shadow: 0 1px 6px 0 rgba(32,33,36,0.28);
    border-color: rgba(223,225,229,0);
    outline: none;
}

.ask-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    border: 1px solid transparent;
    border-radius: 18px;
    background: #f8f9fa;
    color: #3c4043;
    font-size: 13px;
    height: 32px;
    padding: 0 14px;
    cursor: pointer;
    min-width: 86px;
    line-height: 1;
}

.ask-btn:hover {
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    background: #f8f9fa;
    border: 1px solid #dadce0;
}

.ask-btn:focus {
    border: 1px solid #4285f4;
    outline: none;
}

html[data-theme="dark"] .ask-btn {
    background: var(--surface);
    color: var(--text);
}

/* ── Search results ──────────────── */

.search-results {
    margin-top: 18px;
    text-align: left;
}

.search-results-title {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.search-result-item {
    border-bottom: 1px solid var(--border);
    padding: 8px 0 10px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item.is-promoted {
    padding-top: 10px;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 10px;
    line-height: 1;
    color: var(--text-soft);
    padding: 4px 8px;
    margin-bottom: 4px;
}

.search-result-item.is-promoted .result-badge {
    color: var(--primary);
    border-color: rgba(26, 115, 232, 0.4);
}

.result-title {
    display: block;
    color: #1a0dab;
    font-size: 18px;
    line-height: 1.25;
    text-decoration: none;
}

.result-title:hover {
    text-decoration: underline;
}

html[data-theme="dark"] .result-title {
    color: #8ab4f8;
}

.result-url {
    color: #188038;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

html[data-theme="dark"] .result-url {
    color: #81c995;
}

.result-snippet {
    margin: 2px 0 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
}

/* ── Topic chips ─────────────────── */

.topics-row {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.topics-demand { margin-top: 6px; }

.topic-chip {
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 13px;
    height: 32px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
}

.topic-chip:hover { background: var(--hover); }

.topic-chip-soft {
    border-color: transparent;
    background: transparent;
    font-size: 12px;
    height: 28px;
    padding: 0 10px;
    opacity: 0.7;
}

.topic-chip-soft:hover { background: var(--hover); opacity: 1; }

.topics-row-hidden {
    display: none;
}

/* ── AI Response ─────────────────── */

.response {
    margin-top: 20px;
    text-align: left;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    line-height: 1.58;
}

.response h2 {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
}

.response p {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ── Updates drawer ──────────────── */

.updates-drawer {
    margin-top: 28px;
    border-top: 1px solid var(--border);
    text-align: left;
}

.updates-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-soft);
    list-style: none;
    user-select: none;
}

.updates-toggle::-webkit-details-marker{display:none}

.updates-toggle::after {
    content: "›";
    margin-left: auto;
    font-size: 16px;
    font-weight: 300;
    transition: transform 0.15s;
}

.updates-drawer[open] .updates-toggle::after {
    transform: rotate(90deg);
}

.updates-meta {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-soft);
    opacity: 0.5;
}

.updates-grid {
    padding: 0 0 12px;
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
}

.updates-grid h3 {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.updates-list {
    list-style: none;
    margin: 0; padding: 0;
    display: grid;
    gap: 4px;
}

.updates-list li { padding: 2px 0; }

.updates-list a {
    color: var(--primary);
    font-size: 13px;
    line-height: 1.38;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.updates-list a:hover { text-decoration: underline; }

.updates-list span {
    font-size: 11px;
    color: var(--text-soft);
    margin-left: 4px;
}

.sources-line {
    padding: 4px 0 10px;
    font-size: 11px;
    color: var(--text-soft);
}

.sources-line a { color: var(--primary); text-decoration: none; }
.sources-line a:hover { text-decoration: underline; }
.sources-line span { margin: 0 3px; opacity: 0.4; }

/* ── Footer ──────────────────────── */

.microcopy {
    margin: 20px auto 0;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.5;
    max-width: 520px;
    text-align: center;
}

/* ── Responsive ──────────────────── */

@media (max-width: 620px) {
    .app {
        width: calc(100% - 24px);
        padding-top: calc(44px + max(12vh, 60px));
    }

    .logo { margin-bottom: 12px; }
    .logo-text, .logo-glow { font-size: 52px; }
    .logo-glow { filter: blur(18px); }
    .logo-net { width: 120%; }
    .subtitle { font-size: 12px; margin-bottom: 18px; }
    .updates-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *,*::before,*::after {
        animation: none !important;
        transition: none !important;
    }
    .logo-text { animation: gradShift 10s ease-in-out infinite !important; }
    .logo-text > span { opacity: 1 !important; transform: none !important; }
    .net-edges line { animation: edgePulse 6s ease-in-out infinite !important; stroke-dashoffset: 0 !important; }
    .net-nodes circle { animation: nodePulse 4s ease-in-out infinite !important; transform: scale(1) !important; }
    .logo-glow { animation: glowPulse 6s ease-in-out infinite !important; }
}
