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

:root {
    --bg: #fff;
    --text: #000;
    --text-muted: #333;
    --border: #ccc;
    --input-bg: #fff;
    --input-border: #ccc;
    --btn-bg: #333;
    --btn-hover: #555;
    --btn-text: #fff;
    --controls-bg: #fff;
    --controls-border: #333;
    --controls-text: #333;
    --danger: #c00;
    --danger-hover: #e00;
    --success-color: #080;
    --error-color: #c00;
}

body.dark {
    --bg: #1a1a2e;
    --text: #e0e0e0;
    --text-muted: #b0b0b0;
    --border: #333;
    --input-bg: #2a2a3e;
    --input-border: #444;
    --btn-bg: #444;
    --btn-hover: #555;
    --btn-text: #e0e0e0;
    --controls-bg: #2a2a3e;
    --controls-border: #555;
    --controls-text: #e0e0e0;
    --danger: #e44;
    --danger-hover: #e66;
    --success-color: #6c6;
    --error-color: #e66;
}

body {
    font-family: sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    background: var(--bg);
    color: var(--text);
    font-size: 2em;
}

/* ——— hamburger toggle ——— */
#menu-toggle {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 31;
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text);
    line-height: 1;
    display: flex;
    align-items: center;
}

/* ——— nav slide-in panel ——— */
nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: 260px;
    z-index: 30;
    background: var(--bg);
    flex-direction: column;
    padding: 1rem;
    gap: 0.75rem;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
}

nav.open {
    transform: translateX(0);
}

nav a {
    text-decoration: none;
    color: var(--text-muted);
}

nav a:hover {
    text-decoration: underline;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: none;
    text-align: left;
}

.nav-btn:hover {
    text-decoration: underline;
}

#theme-toggle {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 0.25rem;
    align-self: flex-start;
}

#theme-toggle:hover {
    background: none;
    opacity: 0.7;
}

/* ——— backdrop ——— */
.nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0,0,0,0.5);
    display: none;
}

.nav-backdrop.visible {
    display: block;
}

h1 {
    margin-bottom: 1rem;
}

h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text);
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background: var(--btn-bg);
    color: var(--btn-text);
    cursor: pointer;
}

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

button.danger {
    background: var(--danger);
}

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

.error {
    color: var(--error-color);
    margin-bottom: 0.5rem;
}

.success {
    color: var(--success-color);
    margin-bottom: 0.5rem;
}

#post-container {
    text-align: center;
    margin: 0;
    position: relative;
}

html.feed, body.feed {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

body.feed {
    max-width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
}

body.feed #post-container {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 0;
}

body.feed .media {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

body.feed #ad-badge {
    z-index: 1;
}

.media-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    z-index: 2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

body.feed #controls {
    position: fixed;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.empty-feed {
    text-align: center;
    margin: 2rem 0;
}

#ad-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    letter-spacing: 0.05em;
    z-index: 1;
}

.media {
    border-radius: 4px;
    max-width: 100%;
}

.post-card {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.post-card p {
    margin-top: 0.5rem;
}

#controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

#controls a,
#controls button {
    text-decoration: none;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--controls-text);
}

.heart {
    color: var(--controls-text);
    display: flex;
    align-items: center;
}

.heart .heart-filled {
    display: none;
}

.heart.liked {
    color: red;
}

.heart.liked .heart-outline {
    display: none;
}

.heart.liked .heart-filled {
    display: block;
}

input[type="file"] {
    margin-bottom: 0.5rem;
    color: var(--text);
}

#upload-list {
    margin-top: 1rem;
}

.upload-item {
    margin-bottom: 0.75rem;
}

.upload-filename {
    font-weight: bold;
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.progress-bar {
    height: 1.2em;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--success-color);
    border-radius: 4px;
    transition: width 0.2s ease;
}

.upload-status {
    color: var(--text-muted);
    margin-bottom: 0;
}

.upload-status.success {
    color: var(--success-color);
}

.upload-status.error {
    color: var(--error-color);
}

.share-menu {
    display: none;
    position: absolute;
    background: var(--controls-bg);
    border: 1px solid var(--controls-border);
    border-radius: 6px;
    padding: 0.25rem 0;
    z-index: 100;
    min-width: 10rem;
}

.share-menu.visible {
    display: block;
}

.share-menu-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    border: none;
    border-radius: 0;
    background: none;
    color: var(--controls-text);
    font-size: 1em;
    cursor: pointer;
    text-decoration: none;
}

.share-menu-item:hover {
    background: var(--btn-hover);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.pagination a {
    text-decoration: none;
    color: var(--text-muted);
}

.pagination a:hover {
    text-decoration: underline;
}

.page-jump {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-jump input[type="number"] {
    width: 4em;
    padding: 0.25rem 0.5rem;
    text-align: center;
}
