:root {
    --bg-primary: #f4f4f9;
    --bg-secondary: #fff;
    --bg-tertiary: #f8f9fa;
    --bg-sidebar: #333;
    --text-primary: #333;
    --text-secondary: #777;
    --text-muted: #888;
    --text-sidebar: #fff;
    --text-sidebar-muted: #ccc;
    --border-color: #ddd;
    --border-hover: #eee;
    --accent-color: #007bff;
    --accent-hover: #0056b3;
    --accent-text: #fff;
    --shadow: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 2px 8px rgba(0,0,0,0.1);
    --avatar-placeholder: #e0e0e0;
    --avatar-text: #777;
    --sidebar-hover: rgba(255,255,255,0.1);
    --sidebar-border: #444;
}

[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-sidebar: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --text-muted: #666;
    --text-sidebar: #fff;
    --text-sidebar-muted: #888;
    --border-color: #333;
    --border-hover: #444;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-text: #fff;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-lg: 0 2px 8px rgba(0,0,0,0.5);
    --avatar-placeholder: #333;
    --avatar-text: #888;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-border: #333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    min-width: 320px;
    transition: background-color 0.3s, color 0.3s;
}

.app-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    overflow-y: auto;
    transition: background 0.3s;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-profile-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sidebar-border);
}

.sidebar-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--sidebar-border);
    color: var(--text-sidebar-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid var(--sidebar-border);
}

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-sidebar-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    width: auto;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--text-sidebar);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.nav-item {
    color: var(--text-sidebar-muted);
    text-decoration: none;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-sidebar);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item span {
    flex: 1;
}

/* Main Content Area */
.content-area {
    overflow-y: auto;
    padding: 30px;
    transition: background-color 0.3s;
}

/* Helper for content width limitation if needed within main */
.container {
    max-width: 800px;
    margin: 0 auto;
}

/* Existing Component Styles */
.feed {
    margin-top: 0;
}

h2 {
    margin-top: 0;
    color: var(--text-primary);
}

.note {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: background 0.3s, border 0.3s;
}

.note-meta {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-hover);
    padding-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.note-content {
    word-wrap: break-word;
    color: var(--text-primary);
}

.note-content p {
    margin: 0 0 10px 0;
}

.note-content p:last-child {
    margin-bottom: 0;
}

.embedded-image {
    max-width: 100%;
    max-height: 500px;
    display: block;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
}

.post-form-container, .login-container {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin: 0 auto;
    transition: background 0.3s;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-primary);
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s, border 0.3s, color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

button {
    background: var(--accent-color);
    color: var(--accent-text);
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 16px;
    width: 100%;
    transition: background 0.2s;
}

button:hover {
    background: var(--accent-hover);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: auto 1fr;
        grid-template-rows: 100vh;
        height: 100vh;
        overflow: hidden;
    }
    .sidebar {
        padding: 10px 8px;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
        z-index: 10;
        grid-column: 1;
        grid-row: 1;
    }
    .content-area {
        grid-column: 2;
        grid-row: 1;
        padding: 15px;
        overflow-y: auto;
    }
    .sidebar-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 15px;
        padding-bottom: 15px;
        align-items: center;
    }
    .sidebar-profile {
        justify-content: center;
    }
    .sidebar-profile-link {
        flex-direction: column;
    }
    .theme-toggle {
        display: none;
    }
    .sidebar nav {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    .nav-item {
        padding: 12px;
        margin-bottom: 0;
        font-size: 14px;
        flex: 0 0 auto;
        min-width: auto;
        justify-content: center;
    }
    .nav-item span {
        display: none;
    }
    .nav-item svg {
        width: 24px;
        height: 24px;
    }
    .post-form-container, .login-container {
        width: 100%;
        padding: 15px;
        box-sizing: border-box;
    }
}

/* Specific tweaks for very small screens */
@media (max-width: 400px) {
    .sidebar {
        padding: 8px 6px;
    }
    .sidebar nav {
        gap: 6px;
    }
    .nav-item {
        padding: 10px;
    }
    .nav-item svg {
        width: 20px;
        height: 20px;
    }
    .sidebar-avatar,
    .sidebar-avatar-placeholder {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

/* New Styles for Enhanced Feed */
.note-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
}

.note-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    background-color: var(--avatar-placeholder);
    flex-shrink: 0;
}

.note-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
    background-color: var(--avatar-placeholder);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--avatar-text);
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.note-info {
    flex-grow: 1;
}

.note-author-name {
    display: block;
    font-weight: bold;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.2;
}

.note-date {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Parent Note Styles (Replies) */
.parent-note {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--border-color);
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: 0 4px 4px 0;
    font-size: 14px;
    transition: background 0.3s;
}

.parent-note-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 14px;
}

.parent-avatar-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

.parent-author-name {
    font-weight: 600;
    margin-right: 5px;
}

.parent-note-content {
    color: var(--text-primary);
    white-space: pre-wrap;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Profile Header Styles */
.profile-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    box-shadow: var(--shadow-lg);
    transition: background 0.3s, border 0.3s;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--avatar-placeholder);
    flex-shrink: 0;
}

.profile-avatar-large-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--avatar-placeholder);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: var(--avatar-text);
    flex-shrink: 0;
}

.profile-info-main {
    flex-grow: 1;
}

.profile-name-large {
    font-size: 29px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.profile-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.follow-button {
    background: var(--accent-color);
    color: var(--accent-text);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    width: auto;
}

.follow-button:hover {
    background: var(--accent-hover);
}

.unfollow-button {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    width: auto;
    transition: all 0.2s;
}

.unfollow-button:hover {
    background: var(--bg-tertiary);
    border-color: #ef4444;
    color: #ef4444;
}

.profile-pubkey-small {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 15px;
    word-break: break-all;
}

.profile-bio {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 15px;
    white-space: pre-wrap;
}

.profile-website a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.profile-website a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
    }
}

/* Nested Replies */
.nested-replies {
    margin-top: 10px;
    margin-left: 20px;
    padding-left: 10px;
}

.nested-replies.limit-depth {
    margin-left: 0;
    border-left: none;
    padding-left: 0;
}

.reply-note {
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    margin-bottom: 8px;
    padding: 10px;
    box-shadow: none;
    transition: background 0.3s, border 0.3s;
}

.reply-note .note-avatar {
    width: 32px;
    height: 32px;
}

.reply-note .note-avatar-placeholder {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

/* Collapsible Replies */
.collapse-toggle {
    float: right;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: monospace;
    cursor: pointer;
    padding: 5px 10px;
    font-size: 13px;
    width: auto;
    transition: color 0.2s, background 0.2s;
}

.collapse-toggle:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.collapsed-indicator {
    padding: 5px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    border: 1px dashed var(--border-color);
    margin-top: 5px;
}

/* New Classes for Inline Styles Removal */
.error-message {
    color: #ef4444;
    padding: 10px;
    border: 1px solid #ef4444;
    border-radius: 4px;
    margin-bottom: 15px;
    background: var(--bg-tertiary);
}

.error-message-small {
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 15px;
    background: var(--bg-tertiary);
}

.parent-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.replying-to-label {
    margin-right: 5px;
}

.author-link {
    text-decoration: none;
    color: inherit;
}

.note-date-link {
    text-decoration: none;
    color: inherit;
}

.reply-count {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: 14px;
    text-decoration: none;
    vertical-align: middle;
}

.pagination-container {
    text-align: center;
    margin-top: 20px;
}

.load-more-button {
    display: inline-block;
    background: var(--accent-color);
    color: var(--accent-text);
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s;
}

.load-more-button:hover {
    background: var(--accent-hover);
}

.main-post-content {
    font-size: 19px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.reply-form {
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background 0.3s, border 0.3s;
}

.reply-textarea {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s, border 0.3s, color 0.3s;
}

.reply-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.submit-reply-button {
    margin-top: 10px;
    width: auto;
}

.profile-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-card-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.follow-button-small {
    background: var(--accent-color);
    color: var(--accent-text);
    border: none;
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
    width: auto;
}

.follow-button-small:hover {
    background: var(--accent-hover);
}

.unfollow-button-small {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
    width: auto;
}

.unfollow-button-small:hover {
    background: var(--bg-tertiary);
    border-color: #ef4444;
    color: #ef4444;
}

.profile-card-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-card-avatar-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--avatar-placeholder);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--avatar-text);
}

.profile-card-name {
    font-weight: bold;
    font-size: 18px;
    color: var(--text-primary);
}

.profile-card-nip05 {
    color: var(--text-secondary);
    font-size: 14px;
}

.profile-card-about {
    margin-top: 10px;
    color: var(--text-primary);
}

.profile-card-pubkey {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.logged-in-status {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
