:root {
    --background: #0E0D0A;
    --surface: #181613;
    --text-primary: #EDE9E0;
    --text-muted: #8B8579;
    --border: #2A2620;
    --accent: #F38020;
    --accent-glow: rgba(243, 128, 32, 0.15);
    --error: #E5645B;
    --serif: 'Fraunces', Georgia, serif;
    --sans: 'Inter Tight', -apple-system, system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

body {
    background-color: var(--background);
    background-image:
            radial-gradient(ellipse 80% 50% at 50% 0%, rgba(243, 128, 32, 0.05) 0%, transparent 60%),
            radial-gradient(ellipse 60% 40% at 90% 100%, rgba(243, 128, 32, 0.03) 0%, transparent 60%);
    color: var(--text-primary);
    font-family: var(--sans);
    line-height: 1.6;
    min-height: 100vh;
    padding: 64px 24px 48px;
}

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

header {
    margin-bottom: 56px;
}

h1 {
    font-family: var(--serif);
    font-size: 72px;
    font-weight: 400;
    letter-spacing: -0.035em;
    line-height: 0.95;
    margin-bottom: 20px;
    font-variation-settings: "opsz" 144;
}

h1 .accent {
    color: var(--accent);
    font-style: italic;
    font-variation-settings: "opsz" 144;
}

.subtitle {
    color: var(--text-muted);
    font-size: 16px;
    max-width: 520px;
}

.ask-form {
    margin-bottom: 48px;
}

.input-wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    transition: border-color 220ms ease, box-shadow 220ms ease;
}

.input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

input[type="text"] {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    font-family: var(--sans);
    font-size: 17px;
    padding: 20px 24px;
    outline: 0;
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

button[type="submit"] {
    background: transparent;
    border: 0;
    border-left: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 12px;
    padding: 0 28px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: color 220ms ease;
}

button[type="submit"]:hover:not(:disabled) {
    color: var(--accent);
}

button[type="submit"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.section-label {
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.answer-section {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 480ms ease, transform 480ms ease;
    margin-bottom: 56px;
}

.answer-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.answer-text {
    font-family: var(--serif);
    font-size: 21px;
    line-height: 1.55;
    font-variation-settings: "opsz" 14;
    margin-bottom: 36px;
    white-space: pre-wrap;
}

.answer-text sup a {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
    font-style: normal;
    padding: 0 1px;
    top: -0.5em;
}

.answer-text sup a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sources-list {
    list-style: none;
}

.source-item {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 13px;
    scroll-margin-top: 32px;
}

.source-item:last-child {
    border-bottom: 0;
}

.source-number {
    color: var(--accent);
    flex-shrink: 0;
}

.source-link {
    color: var(--text-muted);
    text-decoration: none;
    word-break: break-all;
    transition: color 220ms ease;
}

.source-link:hover {
    color: var(--text-primary);
}

.loading {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 13px;
}

.dots {
    display: inline-flex;
    gap: 5px;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* clear button — appears when the input has content */
.clear-button {
    background: transparent;
    border: 0;
    border-left: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 18px;
    padding: 0 18px;
    transition: color 220ms ease;
    display: none;
    align-items: center;
}

.input-wrap.has-content .clear-button {
    display: flex;
}

.clear-button:hover {
    color: var(--accent);
}

@keyframes pulse {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

.error-box {
    color: var(--error);
    font-family: var(--mono);
    font-size: 13px;
    padding: 16px 20px;
    border: 1px solid rgba(229, 100, 91, 0.3);
    border-radius: 6px;
    background: rgba(229, 100, 91, 0.05);
}

footer {
    margin-top: 96px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 600px) {
    h1 { font-size: 48px; }
    .answer-text { font-size: 18px; }
    input[type="text"] { font-size: 15px; padding: 16px 18px; }
    button[type="submit"] { padding: 0 18px; }
}