:root {
    --text: #1a1a1a;
    --muted: #6b6b6b;
    --accent: #b3261e;
    --border: #e2e2e2;
    --bg: #fafafa;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0 0 16px;
}

.logo a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    cursor: pointer;
}

.logo a:hover {
    color: var(--accent);
}

.logo a::first-letter {
    color: var(--accent);
}

#search-input {
    width: 100%;
    font-size: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

#search-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: transparent;
}

.search-indicator {
    display: none;
}

.htmx-request .search-indicator,
.htmx-request.search-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.results {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.result {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.result:hover {
    background: #f0f0f0;
}

.result .thumb {
    width: 46px;
    height: 69px;
    flex: none;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.result .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.result .title {
    font-weight: 600;
    display: block;
}

.result .meta {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.result .meta span + span::before {
    content: "·";
    margin: 0 6px;
}

.no-results {
    color: var(--muted);
    margin-top: 16px;
}

.movie, .person {
    margin-top: 16px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-row .logo {
    margin: 0;
}

.site-search {
    position: relative;
}

.site-search #search-input {
    width: 160px;
    font-size: 14px;
    padding: 8px 12px;
    transition: width 150ms ease;
}

.site-search #search-input:focus {
    width: 260px;
}

.search-overlay {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: min(420px, calc(100vw - 32px));
    max-height: 60vh;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 8px 12px;
    z-index: 10;
    display: none;
}

.site-search:focus-within .search-overlay:not(:empty) {
    display: block;
}

.search-overlay .results {
    margin: 0;
    border: none;
    border-radius: 0;
}

.search-overlay .no-results {
    margin-top: 4px;
}

.movie-head, .person-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.poster {
    width: 140px;
    border-radius: 8px;
    flex: none;
}

.profile {
    width: 100px;
    border-radius: 8px;
    flex: none;
}

.movie h2, .person h2 {
    margin: 0 0 4px;
}

.original-title {
    color: var(--muted);
    font-style: italic;
    margin: 0 0 4px;
}

.meta-line {
    color: var(--muted);
    margin: 0;
}

.meta-line span + span::before {
    content: "·";
    margin: 0 6px;
}

.overview {
    margin: 0 0 16px;
}

.credits h3, .filmography h3 {
    margin: 16px 0 4px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}

.crew, .filmography ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.crew li, .filmography li {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.crew li:last-child, .filmography li:last-child {
    border-bottom: none;
}

.crew a, .filmography a {
    color: var(--accent);
    text-decoration: none;
}

.crew a:hover, .filmography a:hover {
    text-decoration: underline;
}

.role {
    color: var(--muted);
    font-size: 13px;
    margin-left: 8px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin: 12px 0 16px;
    flex-wrap: wrap;
}

.tabs a {
    padding: 4px 12px;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    font-size: 14px;
}

.tabs a:hover {
    background: #f0f0f0;
}

.tabs a.current {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

.error-page {
    margin-top: 32px;
}

.error-fragment {
    margin: 12px 0 0;
    color: var(--muted);
}

#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100;
    background: var(--accent);
    animation: topbar-slide 1s ease-in-out infinite;
}

@keyframes topbar-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.external-links {
    margin: 8px 0 0;
    font-size: 13px;
}

.external-links a {
    color: var(--muted);
    text-decoration: none;
}

.external-links a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.tmdb-footer {
    max-width: 640px;
    margin: 48px auto 0;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}

.tmdb-footer p {
    margin: 0;
}

.tmdb-footer img {
    height: 12px;
}

@media (max-width: 480px) {
    .movie-head, .person-head {
        flex-direction: column;
    }
}