:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #1c232b;
  --muted: #64707d;
  --line: #d8dee5;
  --accent: #117a8b;
  --accent-strong: #0b5562;
  --danger-bg: #fde8e5;
  --danger-text: #8a2417;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
}

.topbar nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.topbar form {
  margin: 0;
}

.shell {
  margin: 0 auto;
  max-width: 1120px;
  padding: 28px 20px;
}

.layout {
  display: grid;
  gap: 24px;
  justify-content: center;
}

.layout.with-sidebar {
  align-items: start;
  grid-template-columns: minmax(0, 680px) minmax(240px, 320px);
}

.main-column,
.auth-panel {
  margin: 0 auto;
  max-width: 680px;
  width: 100%;
}

.auth-panel,
.composer,
.post,
.comment,
.sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-panel,
.sidebar {
  padding: 24px;
}

h1,
h2 {
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0 0 18px;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.25rem;
}

.form-stack,
.composer,
.comment-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  font-weight: 700;
  gap: 6px;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 38px;
  padding: 8px 14px;
}

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

button.secondary {
  background: #ffffff;
  color: var(--accent-strong);
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-strong);
  font-weight: 700;
  min-height: auto;
  padding: 0;
}

.link-button:hover {
  background: transparent;
  text-decoration: underline;
}

.composer {
  margin-bottom: 18px;
  padding: 16px;
}

.composer-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.composer-preview[hidden] {
  display: none;
}

.composer-preview-frame {
  background: #eef1f4;
  display: grid;
  min-height: 180px;
  place-items: center;
}

.composer-preview-media {
  display: block;
  max-height: 420px;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.composer-preview-meta {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 0.92rem;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 12px;
}

.composer-preview-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-actions,
.post-actions,
.profile-header,
.user-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.file-picker {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
}

.file-picker input {
  display: none;
}

.post-list {
  display: grid;
  gap: 14px;
}

.post {
  overflow: hidden;
  padding: 16px;
}

.post-header {
  display: flex;
  justify-content: space-between;
}

.username {
  color: var(--text);
  font-weight: 800;
}

.muted,
.repost-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.post-body,
.comment p {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.post-media {
  background: #eef1f4;
  border-radius: 8px;
  display: block;
  margin: 12px 0;
  max-height: 560px;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.post-actions {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.post-actions form,
.user-row form {
  margin: 0;
}

.comment-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0;
  padding: 16px;
}

.comments {
  display: grid;
  gap: 12px;
}

.comment {
  padding: 14px;
}

.profile-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 18px;
}

.user-row {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.user-row:first-of-type {
  border-top: 0;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  background: #e8f3f5;
  border: 1px solid #b8dbe1;
  border-radius: 8px;
  padding: 10px 12px;
}

.flash.error {
  background: var(--danger-bg);
  border-color: #f3b8af;
  color: var(--danger-text);
}

.empty-state {
  color: var(--muted);
  margin: 24px 0;
  text-align: center;
}

@media (max-width: 860px) {
  .layout.with-sidebar {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px;
  }

  .shell {
    padding: 20px 14px;
  }

  .composer-actions,
  .profile-header {
    align-items: stretch;
    flex-direction: column;
  }
}
