body {
  max-width: 800px;
  padding: 0 8px;
  margin: 0 auto;
  font-family: Tahoma, Verdana, sans-serif;
  word-wrap: break-word;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--primary);
}

body.light {
  --bg: rgb(232, 232, 232);
  --primary: black;
  --secondary: rgb(144, 144, 144);
  --tertiary: rgb(188, 188, 188);
}

body.dark {
  --bg: black;
  --primary: rgb(144, 144, 144);
  --secondary: rgb(88, 88, 88);
  --tertiary: rgb(44, 44, 44);
}

.secondary { color: var(--secondary); }
hr, input, textarea { border-color: var(--secondary); }
::placeholder { color: var(--secondary); }

main {
  flex: 1;
}

a {
  text-decoration: none;
  color: inherit;
  user-select: none;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

p { margin: 0; }
h4 { margin: 0; }
hr { margin: 5px 0; }

button {
  all: unset;
  cursor: pointer;
  border-radius: 0.25rem;
}

button:active {
  background-color: gray;
}

.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}

input,
textarea {
  background-color: inherit;
  color: inherit;
  border: 1px solid;
  padding: 5px;
  box-sizing: border-box;
  outline: none;
}

/* header */
header {
  display: flex;
  align-items: center;
}

header h1 {
  margin: 0;
  margin-right: 30px;
}

header nav {
  display: flex;
}

header nav a {
  text-decoration: none;
  margin-right: 40px;
}

/* footer */
footer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

footer nav {
  display: flex;
}

footer nav a,
footer nav button {
  text-decoration: none;
  margin: 0 10px;
}

footer p {
  padding-top: 4px;
}

/* auth pages */
.auth-page {
  display: flex;
  justify-content: center;
  padding-top: 64px;
}

.auth-page form div + div {
  padding-top: 4px;
}

.auth-page form button {
  padding: 4px 0;
}

.auth-link {
  font-size: 0.875rem;
}

.error {
  color: red;
}

.w-full { width: 100%; }
.bold { font-weight: bold; }

.center-column {
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

/* message box (error pages) */
.message-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  aspect-ratio: 2;
}

.message-box.error p {
  color: red;
}

/* feed + posts */
.post-card { margin-bottom: 5px; }

.post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.post-media { margin-bottom: 4px; }

.post-media img,
.post-media video {
  width: 100%;
  height: auto;
  display: block;
}

.post-caption {
  margin-top: 4px;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0;
}

/* comments */
.comment-section { margin-top: 8px; }

.comment-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.comment-form input {
  flex: 1;
}

.comment-form button {
  border: 1px solid;
  padding: 5px 10px;
}

.comment {
  margin-bottom: 8px;
}

.comment .bold {
  margin-right: 6px;
}

/* profile */
.profile-header {
  margin-bottom: 10px;
}

.profile-header h2 {
  margin-bottom: 4px;
}

.profile-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.post-grid-item {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
}

.post-grid-item img,
.post-grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* search */
.search-page input {
  margin-bottom: 10px;
}

.search-result {
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-empty {
  margin-top: 10px;
}

.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  margin-bottom: 4px;
}

.link-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

.link-btn:hover {
  opacity: 0.7;
}

/* upload */
.upload-page form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 500px;
}

.upload-page form button {
  border: 1px solid;
  padding: 5px;
  text-align: center;
}

.upload-page form button:hover {
  text-decoration: underline;
}

/* responsive */
@media (max-width: 550px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  header nav {
    margin-bottom: 10px;
  }

  header nav a {
    margin-right: 20px;
  }
}
