:root {
  --bg: #0f0e0d;
  --fg: #f5f3ef;
  --muted: #8f8a82;
  --accent: #d4a373;
  --card: #1a1816;
  --border: #2a2724;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.btn {
  background: var(--fg);
  color: var(--bg);
  border: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}

.btn:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.post-author {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.post-time {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.post-body {
  margin: 0 0 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post-image, .post-video {
  width: 100%;
  border-radius: 10px;
  margin: 8px 0 12px;
  display: block;
  max-height: 480px;
  object-fit: cover;
  background: #000;
}
.post-video { object-fit: contain; }

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0;
}

.reactions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reaction {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
}

.reaction.mine {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.compose {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}

.compose textarea {
  width: 100%;
  min-height: 80px;
  background: transparent;
  border: 0;
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  outline: none;
}

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.empty p { margin: 4px 0; }

.login {
  max-width: 380px;
  margin: 10vh auto;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login h2 {
  margin: 0 0 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
}

.login input:focus {
  border-color: var(--accent);
}

/* Login tabs */
.login-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: var(--card);
  color: var(--fg);
  font-weight: 600;
}

.error {
  color: #e08080;
  font-size: 14px;
  margin-top: 8px;
}

/* Post header */
.post-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.post-author { font-weight: 600; font-size: 14px; }
.post-time   { color: var(--muted); font-size: 12px; }

/* Compose image */
.compose-preview {
  position: relative;
  margin: 8px 0;
}
.compose-preview-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}
.compose-clear-img {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: 0;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 13px;
  cursor: pointer;
  line-height: 26px;
  text-align: center;
}
.btn-icon {
  padding: 8px 10px;
  font-size: 16px;
}
.btn-sm {
  background: var(--fg);
  color: var(--bg);
  border: 0;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.btn-sm:disabled { opacity: 0.5; cursor: default; }

/* Comments */
.comments-toggle {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 8px;
  font-family: inherit;
}
.comments-toggle:hover { color: var(--fg); }

.comments {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.comment-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.comment-author {
  font-weight: 600;
  font-size: 13px;
}
.comment-time {
  color: var(--muted);
  font-size: 11px;
}
.comment-body {
  margin: 0;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-compose {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.comment-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.comment-input:focus { border-color: var(--accent); }
