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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

nav h1 {
    font-size: 1.5rem;
}

nav h1 a {
    color: white;
    text-decoration: none;
}

nav h1 a:hover {
    color: #3498db;
}

.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-form input[type="search"] {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 250px;
}

.search-form button {
    padding: 0.5rem 1.5rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.search-form button:hover {
    background: #2980b9;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    min-height: calc(100vh - 200px);
}

h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Thread List - Compact Email Client Style */
.thread-list {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0.5rem;
}

.email-item {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.email-item:hover {
    background: #f5f9ff;
}

/* Read/Unread styles */
.email-item.read .email-from {
    font-weight: 400;
    color: #666;
}

.email-item.read .email-subject {
    color: #888;
    font-weight: 400;
}

.email-item.read .email-date {
    color: #aaa;
}

.email-line {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.email-from {
    color: #2c3e50;
    font-weight: 600;
    min-width: 120px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-subject {
    color: #444;
    text-decoration: none;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-subject:hover {
    color: #3498db;
    text-decoration: underline;
}

.email-date {
    color: #888;
    font-size: 0.85rem;
    min-width: 140px;
    text-align: right;
    flex-shrink: 0;
}

/* Thread View */
.thread-container {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message {
    margin-bottom: 2rem;
    padding: 1rem;
    border-left: 3px solid #3498db;
    background: #f9f9f9;
    border-radius: 4px;
    scroll-margin-top: 2rem;
}

.message:target {
    background: #fff8dc;
    border-left-color: #f39c12;
}

.message-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.message-header strong {
    color: #2c3e50;
    font-size: 1.1rem;
}

.message-date {
    color: #666;
    font-size: 0.9rem;
    margin-left: 1rem;
}

.permalink {
    float: right;
    color: #3498db;
    text-decoration: none;
    font-size: 0.85rem;
}

.permalink:hover {
    text-decoration: underline;
}

.message-body {
    color: #444;
    overflow-wrap: break-word;
}

.message-body pre {
    white-space: pre-wrap;
    font-family: inherit;
}

.message-body a {
    color: #3498db;
}

/* Single Message View */
.message-single {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-meta {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.message-meta p {
    margin-bottom: 0.5rem;
}

/* Search Results */
.search-results {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-result {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

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

.search-result h3 {
    margin-bottom: 0.5rem;
}

.search-result h3 a {
    color: #2c3e50;
    text-decoration: none;
}

.search-result h3 a:hover {
    color: #3498db;
}

.result-meta {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.result-preview {
    color: #555;
    margin-bottom: 0.5rem;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

/* Links */
a {
    color: #3498db;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-form input[type="search"] {
        min-width: 200px;
    }

    main {
        padding: 0 1rem;
    }

    .message {
        margin-left: 0 !important;
        padding-left: 1rem;
    }
}
