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

:root {
    --bg: #1a1a1a;
    --bg-card: #242424;
    --bg-input: #2a2a2a;
    --border: #333333;
    --text: #e0e0e0;
    --text-muted: #888888;
    --accent: #4a9eff;
    --accent-hover: #6cb4ee;
    --error: #e05555;
    --success: #55b87a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.25rem;
    width: 100%;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    margin-bottom: 2rem;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.site-title:hover {
    text-decoration: none;
    color: var(--text);
}
.site-header nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.site-header nav a {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.site-header nav a:hover {
    color: var(--text);
    text-decoration: none;
}

/* Post list */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.post-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-card);
}
.post-card-media {
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}
.post-card-media img,
.post-card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.video-thumb {
    position: relative;
    width: 100%;
    height: 100%;
}
.video-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    color: white;
    background: rgba(0,0,0,0.5);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    pointer-events: none;
}
.post-card-body {
    padding: 1rem 1.25rem 1.25rem;
}
.post-card-body time {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.post-card-body h2 {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.25rem;
    line-height: 1.3;
}
.post-card-body h2 a {
    color: var(--text);
}
.post-card-body h2 a:hover {
    color: var(--accent);
    text-decoration: none;
}
.post-excerpt {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.read-more {
    font-size: 0.9rem;
}

/* Single post */
.post-full {
    margin-bottom: 3rem;
}
.post-featured-media {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.post-featured-media video,
.post-featured-media img {
    width: 100%;
    display: block;
}
.post-content time {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.post-content h1 {
    margin: 0.25rem 0 1.25rem;
    font-size: 1.75rem;
    line-height: 1.3;
}
.post-body {
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 2rem;
}
.post-body p {
    margin-bottom: 1rem;
}
.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Gallery */
.post-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.gallery-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-card);
}
.gallery-item img,
.gallery-item video {
    width: 100%;
    display: block;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}
.gallery-item figcaption {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Media description */
.media-description {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
.page-link {
    font-size: 0.9rem;
}
.page-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-muted);
}

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

/* Login form */
.login-form {
    max-width: 360px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.login-form h1 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* Forms */
label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
}
textarea {
    resize: vertical;
    min-height: 200px;
}
small {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

button, .submit-button {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
}
button:hover, .submit-button:hover {
    background: var(--accent-hover);
}
.submit-button {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.link-button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.link-button:hover {
    color: var(--text);
}

.inline-form {
    display: inline;
}

/* Upload form */
.upload-form {
    margin-bottom: 3rem;
}
.current-media {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.current-media label {
    display: inline;
    margin-left: 0.5rem;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}
.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
}
.drop-zone p {
    margin: 0;
    font-size: 0.9rem;
}
.drop-zone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* Previews */
.featured-preview,
.gallery-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.preview-item {
    position: relative;
    width: 120px;
    height: 90px;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.preview-item img,
.preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.preview-item .remove-preview {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Posts table */
.existing-posts {
    border-top: 1px solid var(--border);
    padding-top: 2rem;
}
.existing-posts h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}
.posts-table {
    display: flex;
    flex-direction: column;
}
.post-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.post-row-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.post-row-date {
    color: var(--text-muted);
    white-space: nowrap;
}
.post-row-actions {
    display: flex;
    gap: 0.75rem;
    white-space: nowrap;
}
.post-row-actions a {
    font-size: 0.85rem;
}
.delete-post-btn {
    background: none;
    border: none;
    color: var(--error);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.delete-post-btn:hover {
    text-decoration: underline;
}

/* Messages */
.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.message.success {
    background: rgba(85, 184, 122, 0.15);
    color: var(--success);
    border: 1px solid rgba(85, 184, 122, 0.3);
}
.message.error {
    background: rgba(224, 85, 85, 0.15);
    color: var(--error);
    border: 1px solid rgba(224, 85, 85, 0.3);
}

/* Bug */
#screen-bug {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    will-change: left, top, transform;
    filter: drop-shadow(0 0 3px rgba(255,255,255,0.15));
}
#screen-bug.bug-moving .bug-wing-l {
    animation: wing-flutter 40ms steps(1) infinite;
}
#screen-bug.bug-moving .bug-wing-r {
    animation: wing-flutter 40ms steps(1) infinite reverse;
}
#screen-bug.bug-moving .bug-leg {
    animation: leg-twitch 55ms steps(1) infinite alternate;
}
@keyframes wing-flutter {
    0%   { opacity: 0.22; transform: scaleY(1); }
    50%  { opacity: 0.08; transform: scaleY(0.4); }
}
@keyframes leg-twitch {
    0%   { transform: translateY(0); }
    100% { transform: translateY(-1px); }
}

/* Responsive */
@media (max-width: 600px) {
    .post-card-body {
        padding: 0.75rem 1rem 1rem;
    }
    .post-content h1 {
        font-size: 1.4rem;
    }
    .post-row {
        flex-wrap: wrap;
    }
    .post-row-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
