/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #6b7280;
    --color-accent: #2563eb;
    --color-accent-hover: #1d4ed8;
    --color-border: #e5e7eb;
    --color-tag-bg: #f3f4f6;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: Georgia, "Times New Roman", serif;
    --max-width: 720px;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.7;
    font-size: 17px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}
a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--color-border);
    padding: 16px 0;
    background: var(--color-surface);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.auth-nav {
    display: flex;
    gap: 12px;
    font-size: 14px;
}
.auth-nav a {
    color: var(--color-text-muted);
}
.auth-nav a:hover {
    color: var(--color-accent);
}
.site-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.5px;
}
.site-logo:hover {
    color: var(--color-accent);
    text-decoration: none;
}
.user-nav-name {
    font-size: 15px;
    color: var(--color-text-muted);
}
a.user-nav-name:hover {
    color: var(--color-accent);
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    margin-top: auto;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Home */
.home-page {
    padding: 60px 0;
    text-align: center;
}
.home-page h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
}
.home-subtitle {
    color: var(--color-text-muted);
    margin-top: 8px;
    font-size: 18px;
}
.user-list {
    list-style: none;
    margin-top: 40px;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}
.user-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.user-list li a {
    font-size: 18px;
    font-weight: 500;
}
.post-count {
    font-size: 14px;
    color: var(--color-text-muted);
}

/* Journal page */
.journal-page {
    padding: 40px 0;
}
.journal-header {
    margin-bottom: 40px;
}
.journal-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.journal-bio {
    color: var(--color-text-muted);
    margin-top: 8px;
}
.filter-info {
    margin-top: 12px;
    font-size: 14px;
    color: var(--color-text-muted);
}

/* Post list */
.post-preview {
    padding: 24px 0;
    border-bottom: 1px solid var(--color-border);
}
.post-preview:first-child {
    padding-top: 0;
}
.post-date {
    display: block;
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.post-title {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.3px;
}
.post-title a {
    color: var(--color-text);
}
.post-title a:hover {
    color: var(--color-accent);
    text-decoration: none;
}

/* Tags */
.post-tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--color-tag-bg);
    border-radius: 12px;
    font-size: 13px;
    color: var(--color-text-muted);
}
.tag:hover {
    background: var(--color-border);
    text-decoration: none;
    color: var(--color-text);
}
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    max-height: 66px;
    margin-top: 12px;
    overflow-y: auto;
    padding-right: 4px;
}
.tag-list-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--color-tag-bg);
    color: var(--color-text-muted);
    font-size: 11px;
    line-height: 1.45;
}
.tag-list-item:hover,
.tag-list-item.is-active {
    background: var(--color-border);
    color: var(--color-text);
    text-decoration: none;
}
.tag-count {
    color: var(--color-text-muted);
    font-size: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 32px 0;
}
.page-link {
    font-size: 15px;
    font-weight: 500;
}
.page-info {
    font-size: 14px;
    color: var(--color-text-muted);
}

/* Post detail */
.post-full {
    padding: 40px 0;
}
.post-header {
    margin-bottom: 32px;
}
.post-header .post-title {
    font-size: 30px;
    font-weight: 700;
    margin-top: 8px;
    letter-spacing: -0.5px;
}

/* Post content */
.post-content {
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.8;
}
.post-content p {
    margin-bottom: 1.2em;
}
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 16px 0;
    display: block;
}
.post-content a.lightbox {
    display: block;
    cursor: zoom-in;
}
.post-content a.lightbox.manual-lightbox {
    display: inline-block;
    max-width: min(100%, 320px);
}
.post-content a.lightbox.manual-lightbox img {
    width: 100%;
}
.post-content a.lightbox:hover img {
    opacity: 0.9;
    transition: opacity 0.15s;
}
.post-content a {
    word-break: break-word;
}
.post-content blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--color-text-muted);
    font-style: italic;
}
.post-content h2, .post-content h3 {
    font-family: var(--font-sans);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
.post-content iframe.ql-video {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
    border-radius: 6px;
    display: block;
    margin: 20px 0;
    background: #000;
}

/* Video wrapper */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    margin: 20px 0;
    border-radius: 6px;
    background: #000;
}
.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Lightbox overlay */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
.lightbox-img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    font-size: 36px;
    color: #fff;
    cursor: pointer;
    z-index: 1001;
    line-height: 1;
    opacity: 0.7;
}
.lightbox-close:hover {
    opacity: 1;
}

/* Post navigation */
.post-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    gap: 16px;
}
.post-nav-link {
    font-size: 15px;
    max-width: 35%;
}
.post-nav-prev {
    text-align: left;
}
.post-nav-up {
    text-align: center;
    flex-shrink: 0;
    font-size: 14px;
    color: var(--color-text-muted);
}
.post-nav-next {
    margin-left: auto;
    text-align: right;
}
.post-full > .post-tags {
    margin-top: 32px;
}

/* Auth pages */
.auth-page {
    max-width: 380px;
    margin: 60px auto;
}
.auth-page h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}
.auth-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    margin-top: 16px;
    color: var(--color-text-muted);
}
.auth-form input[type="text"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 16px;
    font-family: var(--font-sans);
}
.auth-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.auth-form button {
    margin-top: 24px;
    width: 100%;
    padding: 10px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}
.auth-form button:hover {
    background: var(--color-accent-hover);
}
.auth-error {
    color: #dc2626;
    font-size: 14px;
    margin-top: 4px;
}
.auth-success {
    color: #16a34a;
    font-size: 14px;
    margin-bottom: 16px;
}

/* Profile */
.profile-page {
    padding: 40px 0;
    max-width: 520px;
}
.profile-page h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 28px;
}
.profile-section {
    padding: 24px 0;
    border-top: 1px solid var(--color-border);
}
.profile-section h2 {
    font-size: 18px;
    font-weight: 650;
    margin-bottom: 16px;
}
.profile-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    margin-top: 16px;
    color: var(--color-text-muted);
}
.profile-form input[type="text"],
.profile-form input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 16px;
    font-family: var(--font-sans);
}
.profile-form input[type="file"] {
    width: 100%;
    font-size: 14px;
    color: var(--color-text-muted);
}
.profile-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.profile-form button {
    margin-top: 20px;
}
.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}
.profile-avatar {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--color-border);
    background: var(--color-tag-bg);
}
.profile-avatar-default {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-sans);
}
.profile-avatar-fields {
    flex: 1;
    min-width: 0;
}
.profile-avatar-fields label {
    margin-top: 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-sans);
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--color-accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    color: #fff;
}
.btn-secondary {
    background: var(--color-tag-bg);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-border);
    color: var(--color-text);
}
.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}
.btn-danger:hover {
    background: #fecaca;
    color: #b91c1c;
}
.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
}

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

/* Post owner actions */
.post-owner-actions {
    display: flex;
    gap: 8px;
    margin-top: 24px;
    align-items: center;
}
.inline-form {
    display: inline-flex;
    margin: 0;
    padding: 0;
}

/* Friends feed */
.post-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.post-author {
    font-size: 14px;
    font-weight: 500;
}
.journal-header-actions {
    display: flex;
    gap: 8px;
}

/* Feed post preview */
.feed-body {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}
.feed-thumb {
    flex-shrink: 0;
    width: 120px;
    min-width: 120px;
    height: 90px;
    min-height: 90px;
    max-width: 120px;
    max-height: 90px;
    border-radius: 6px;
    overflow: hidden;
    display: block;
}
.feed-thumb img {
    width: 120px !important;
    height: 90px !important;
    max-width: 120px !important;
    max-height: 90px !important;
    object-fit: cover !important;
    display: block;
}
.feed-excerpt {
    font-size: 15px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Friends management page */
.friends-page {
    padding: 40px 0;
    max-width: 500px;
}
.friends-page h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}
.friend-count {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 20px;
}
.friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    gap: 12px;
}
.friend-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}
.friend-name {
    font-size: 16px;
    font-weight: 500;
}
.friend-username {
    font-size: 13px;
    color: var(--color-text-muted);
}
.friend-posts {
    font-size: 13px;
    color: var(--color-text-muted);
}
.friend-action {
    flex-shrink: 0;
}
.friends-search {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.friends-search input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 15px;
    font-family: var(--font-sans);
}
.friends-search input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.friend-row {
    cursor: pointer;
}
.friend-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--color-accent);
}
.friend-status {
    margin-left: auto;
    flex-shrink: 0;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}
.badge-friend {
    background: #dbeafe;
    color: #1d4ed8;
}
.friends-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* Editor page */
.editor-page {
    padding: 40px 0;
    max-width: 800px;
}
.editor-page h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}
.editor-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    margin-top: 20px;
    color: var(--color-text-muted);
}
.editor-form label:first-of-type {
    margin-top: 0;
}
.editor-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 16px;
    font-family: var(--font-sans);
}
.editor-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.tag-input-wrap {
    position: relative;
}
.tag-suggestions {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    display: flex;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.tag-suggestion {
    width: 100%;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.tag-suggestion:hover,
.tag-suggestion.is-active {
    background: var(--color-tag-bg);
}
.editor-content-field {
    display: none;
}
.quill-editor {
    background: #fff;
}
.editor-form .ql-toolbar.ql-snow,
.editor-form .ql-container.ql-snow {
    border-color: var(--color-border);
    font-family: var(--font-sans);
}
.editor-form .ql-toolbar.ql-snow {
    border-radius: 6px 6px 0 0;
}
.editor-form .ql-container.ql-snow {
    min-height: 500px;
    border-radius: 0 0 6px 6px;
}
.editor-form .ql-editor {
    min-height: 500px;
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.7;
}
.editor-form .ql-editor iframe.ql-video {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
}
.editor-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

/* Responsive */
@media (max-width: 600px) {
    body { font-size: 16px; }
    .post-header .post-title { font-size: 24px; }
    .post-content { font-size: 16px; }
    .journal-header h1 { font-size: 24px; }
    .home-page h1 { font-size: 28px; }
}
