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

:root {
  --bg: #15202b;
  --surface: #192734;
  --border: #38444d;
  --text: #e7e9ea;
  --muted: #8899a6;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --error: #f4212e;
  --radius: 16px;
}

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

.page-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  gap: 16px;
  padding: 0 16px;
}

.ads-column {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 24px;
  position: sticky;
  top: 24px;
}

.ads-column.is-hidden {
  display: none;
}

.ad-slot {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  display: none;
}

.ad-slot.has-ad {
  display: block;
}

.ad-slot img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  background: #0f1419;
}

.ads-mobile {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ads-mobile.has-ads {
  display: grid;
}

.ads-mobile img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.app {
  max-width: 600px;
  width: 100%;
  margin: 0;
  min-height: 100vh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(21, 32, 43, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

.compose {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.required {
  color: var(--accent);
}

input[type="text"],
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.counter {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.file-field input[type="file"] {
  display: none;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 0;
}

.file-label:hover {
  color: var(--accent-hover);
}

.error {
  color: var(--error);
  font-size: 0.875rem;
  margin-bottom: 10px;
}

.submit-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9999px;
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feed {
  padding-bottom: 24px;
}

.feed-title {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 16px 16px 8px;
}

.feed-list {
  display: flex;
  flex-direction: column;
}

.loading,
.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
  font-size: 0.9375rem;
}

.post {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7856ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  color: #fff;
}

.post-body {
  flex: 1;
  min-width: 0;
}

.post-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.post-name {
  font-weight: 700;
  font-size: 0.9375rem;
}

.post-time {
  color: var(--muted);
  font-size: 0.8125rem;
}

.post-text {
  margin-top: 4px;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

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

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

.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.compose-actions {
  margin-bottom: 12px;
}

.toggle-poll-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 9999px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
}

.toggle-poll-btn:hover {
  background: var(--surface);
}

.poll-fields {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--surface);
}

.poll-fields input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  margin-bottom: 8px;
  outline: none;
}

.poll-fields input[type="text"]:focus {
  border-color: var(--accent);
}

.poll-fields .poll-opt {
  margin-top: 0;
}

.poll {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.poll-question {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 10px;
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}

.poll-option:hover {
  border-color: var(--accent);
}

.poll-option.voted {
  border-color: var(--accent);
  font-weight: 600;
}

.poll-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(29, 155, 240, 0.15);
  border-radius: 9999px;
  transition: width 0.3s ease;
  z-index: 0;
}

.poll-label,
.poll-meta {
  position: relative;
  z-index: 1;
}

.poll-meta {
  color: var(--muted);
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.poll-total {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.reaction-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.reaction-btn.active {
  background: rgba(29, 155, 240, 0.15);
  border-color: var(--accent);
}

.reaction-count {
  font-size: 0.75rem;
  color: var(--muted);
}

.post-attachment {
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-attachment img {
  display: block;
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  background: #000;
}

.post-attachment video {
  display: block;
  max-width: 100%;
  max-height: 400px;
}

.post-attachment audio {
  width: 100%;
  padding: 8px;
  background: var(--surface);
}

.file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
}

.file-link:hover {
  text-decoration: underline;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .ads-column {
    display: none !important;
  }

  .page-layout {
    padding: 0;
  }
}

@media (max-width: 640px) {
  .app {
    border: none;
  }
}
