:root {
    --twitter-blue: #1DA1F2;
    --bg-gray: #E6ECF0;
    --border-gray: #E1E8ED;
    --thread-line: #CCD6DD;
    --text-black: #14171A;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-black);
    margin: 0;
}

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

.top-nav {
    background: #fff;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-gray);
    position: sticky;
    top: 0;
    z-index: 100;
}

#search-bar {
    width: 100%;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid var(--border-gray);
    background: #F5F8FA;
    box-sizing: border-box;
    flex: 2; /* Search bar takes more space */
}

/* Individual Tweet Card */
.tweet {
    background: #fff;
    padding: 15px;
    border: 1px solid var(--border-gray);
    margin-bottom: 1px;
    position: relative;
}

/*.tweet.is-thread-child::before {
    content: "";
    position: absolute;
    left: 30px;
    top: -15px;
    bottom: 100%;
    width: 2px;
    background-color: var(--thread-line);
}*/

.graph-img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-gray);
    margin-top: 10px;
}

.date {
    font-size: 0.9em;
    color: #657786;
    margin-top: 5px;
}

/* Links inside tweet text */
.content p a {
    color: var(--twitter-blue);
    text-decoration: none;
}

.content p a:hover {
    text-decoration: underline;
}

.tweet {
    transition: opacity 0.2s ease-in-out;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* The container for the whole thread */
.thread-wrapper {
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid var(--border-gray);
    border-radius: 12px;
    overflow: hidden;
}

/* Connect the tweets with a line */
.thread-tweet {
    position: relative;
    padding-left: 60px;
}

.thread-tweet::before {
    content: "";
    position: absolute;
    left: 28px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--thread-line);
}

.thread-tweet:last-child::before {
    display: none;
}

/* Style for external OEmbed tweets */
.external-tweet {
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-gray);
}

.is-clickable {
    cursor: pointer;
}

.is-clickable:hover {
    background-color: #f5f8fa;
}

.back-btn {
    background: var(--twitter-blue);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    margin-bottom: 15px;
    cursor: pointer;
    font-weight: bold;
}

/*.logo-box {
    display: flex;
    justify-content: center;
    padding: 10px;
}*/

.tweet-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
    background: #ccc;
    object-fit: cover;
    display: block;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.stats {
    display: flex;
    margin-top: 12px;
    border-top: 1px solid var(--border-gray);
    padding-top: 10px;
    font-size: 0.9em;
    color: #657786;
}

.stat-item {
    margin-right: 20px;
}

.stat-item strong {
    color: var(--text-black);
}

.load-more-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--border-gray);
    border-top: none;
    color: var(--twitter-blue);
    font-size: 0.95em;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}

.load-more-btn:hover {
    background: #f5f8fa;
}

/* Thread indicator badge */
.thread-badge {
    margin-left: auto;
    font-size: 0.75em;
    font-weight: bold;
    color: var(--twitter-blue);
    border: 1px solid var(--twitter-blue);
    border-radius: 10px;
    padding: 2px 8px;
    white-space: nowrap;
    opacity: 0.8;
}

/* Site header */
.site-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 10px;
}

.twitter-bird {
    width: 32px;
    height: 32px;
    fill: var(--twitter-blue);
    flex-shrink: 0;
}

.site-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.site-title-main {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--text-black);
}

.site-title-sub {
    font-size: 0.8em;
    color: #657786;
}

/* Layout for search and sort side-by-side */
.controls-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.ts-wrapper {
    flex: 1; /* Sort dropdown takes less space */
    min-width: 150px;
}

/* Ensure Tom-Select matches your style */
.ts-control {
    border-radius: 20px !important;
    padding: 8px 12px !important;
    background: #F5F8FA !important;
    border: 1px solid var(--border-gray) !important;
}

/* Site header hover effect */
#home-link:hover .site-title-main {
    color: var(--twitter-blue);
}

.quote-tweet-inset {
    border: 1px solid #cfd9de;
    border-radius: 12px;
    padding: 12px;
    margin-top: 10px;
    cursor: pointer;
    background: #f7f9f9;
    transition: background 0.15s;
}
.quote-tweet-inset:hover { background: #edf3f5; }

.quote-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    margin-bottom: 6px;
}
.avatar-sm { width: 20px; height: 20px; border-radius: 50%; }
.quote-date { color: #536471; }
.quote-body p { margin: 0; font-size: 0.95em; }
.quote-body .graph-img { max-width: 100%; border-radius: 8px; margin-top: 6px; }

.quote-tweet-external {
    border: 1px solid #cfd9de;
    border-radius: 12px;
    margin-top: 10px;
    overflow: hidden;
    /* Constrain Twitter's injected widget */
    max-width: 100%;
}
.quote-tweet-external .twitter-tweet { margin: 0 !important; }

.external-error {
    background: #fff8f0;
    border: 1px solid #f0c0a0;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9em;
    color: #555;
}
.external-error p {
    margin: 0 0 6px 0;
}

#lightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border: none;
    background: transparent;
    padding: 0;
}

#lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox::backdrop {
    background: rgba(0, 0, 0, 0.85);
    cursor: zoom-out;
}

#lightbox-img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    display: block;
    cursor: zoom-out;
    border-radius: 8px;
}

#lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
}
