/* Trendelia — Xiaohongshu-style UI */
:root {
  --accent: #ff2442;
  --accent-dark: #e01e3a;
  --text: #222;
  --muted: #8a8a8a;
  --bg: #f7f7f7;
  --card: #fff;
  --border: #ececec;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0 0 .5em; }
.muted { color: var(--muted); font-weight: 400; }
.error {
  background: #fdecee; color: #b3122c;
  padding: 10px 14px; border-radius: 8px; font-size: 14px;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.logo { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.logo-dot { color: var(--text); }
.search { flex: 1; display: flex; max-width: 480px; }
.search input {
  flex: 1; border: 1px solid var(--border); border-right: 0;
  border-radius: 999px 0 0 999px; padding: 8px 16px;
  font-size: 14px; background: var(--bg); outline: none;
}
.search input:focus { border-color: var(--accent); }
.search button {
  border: 1px solid var(--border); border-left: 0;
  border-radius: 0 999px 999px 0; background: var(--bg);
  padding: 0 14px; cursor: pointer; font-size: 14px;
}
.topnav { display: flex; align-items: center; gap: 14px; margin-left: auto; font-size: 14px; }
.topnav > a:not(.btn):hover { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-block; border: 1px solid var(--accent);
  border-radius: 999px; padding: 7px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--accent);
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { border-color: var(--border); color: var(--muted); background: var(--card); }
.btn-block { width: 100%; }

/* User menu */
.usermenu { position: relative; }
.usermenu-drop {
  display: none; position: absolute; right: 0; top: 40px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.08);
  min-width: 150px; overflow: hidden;
}
.usermenu:hover .usermenu-drop { display: block; }
.usermenu-drop a { display: block; padding: 10px 14px; font-size: 14px; }
.usermenu-drop a:hover { background: var(--bg); }

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-letter {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; user-select: none;
}

/* Layout */
.page { max-width: 1200px; margin: 0 auto; padding: 18px 16px 60px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0 36px; }

/* Category chips */
.channels { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  padding: 6px 16px; border-radius: 999px; font-size: 14px;
  background: var(--card); border: 1px solid var(--border);
}
.chip:hover { color: var(--accent); }
.chip-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.search-info { margin: 0 0 14px; }

/* Masonry feed */
.masonry { column-count: 5; column-gap: 14px; }
@media (max-width: 1100px) { .masonry { column-count: 4; } }
@media (max-width: 900px)  { .masonry { column-count: 3; } }
@media (max-width: 640px)  { .masonry { column-count: 2; } }

.note-card {
  display: inline-block; width: 100%; margin: 0 0 14px;
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  break-inside: avoid; transition: box-shadow .15s ease;
}
.note-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.card-img { width: 100%; }
.card-noimg {
  display: flex; align-items: center; justify-content: center;
  min-height: 180px; padding: 20px; text-align: center;
  background: linear-gradient(135deg, #ffe3e8, #ffd1d9);
  color: #a41530; font-weight: 600;
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 14px; font-weight: 600; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
}
.card-author { display: flex; align-items: center; gap: 6px; min-width: 0; }
.card-author-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.card-likes { flex-shrink: 0; }
.loadmore-wrap { text-align: center; margin: 18px 0; }
.empty { text-align: center; padding: 70px 0; color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* Note page */
.note-page {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
@media (max-width: 860px) { .note-page { grid-template-columns: 1fr; } }
.note-media { background: #111; display: flex; align-items: center; }
.note-noimg { width: 100%; min-height: 320px; }
.carousel { position: relative; width: 100%; }
.carousel-img { display: none; width: 100%; max-height: 80vh; object-fit: contain; margin: 0 auto; }
.carousel-img.active { display: block; }
.carousel-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  border: 0; background: rgba(0,0,0,.45); color: #fff;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 20px; cursor: pointer; line-height: 1;
}
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.carousel-dots {
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); }
.dot.active { background: #fff; }

.note-side { padding: 22px; display: flex; flex-direction: column; min-width: 0; }
.note-author {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.note-author-link { display: flex; align-items: center; gap: 10px; min-width: 0; }
.note-author-link span { display: flex; flex-direction: column; line-height: 1.25; font-size: 14px; }
.note-title { font-size: 20px; margin: 16px 0 8px; }
.note-body { font-size: 15px; white-space: normal; }
.note-info { font-size: 13px; margin: 10px 0 0; }
.note-info a { color: var(--accent); }
.note-actions {
  display: flex; gap: 10px; margin: 16px 0;
  padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.action {
  border: 1px solid var(--border); background: var(--bg);
  border-radius: 999px; padding: 7px 16px; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.action.active { border-color: var(--accent); color: var(--accent); background: #fff0f2; }
.action-static { cursor: default; }

/* Comments */
.comments h2 { font-size: 16px; margin: 6px 0 12px; }
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-main { min-width: 0; }
.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment-main p { margin: 2px 0 0; font-size: 14px; overflow-wrap: break-word; }
#comment-form { display: flex; gap: 8px; margin-top: 12px; }
#comment-form input {
  flex: 1; border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; outline: none; background: var(--bg);
}
#comment-form input:focus { border-color: var(--accent); }

/* Profile */
.profile-head {
  display: flex; align-items: center; gap: 20px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px; flex-wrap: wrap;
}
.profile-info { flex: 1; min-width: 220px; }
.profile-info h1 { font-size: 22px; margin-bottom: 4px; }
.profile-bio { margin: 4px 0; font-size: 14px; }
.profile-stats { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.profile-stats strong { color: var(--text); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { padding: 7px 18px; border-radius: 999px; font-size: 14px; background: var(--card); border: 1px solid var(--border); }
.tab-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Auth / create forms */
.auth-card {
  max-width: 420px; margin: 30px auto; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.create-card { max-width: 560px; }
.auth-card h1 { font-size: 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.auth-card label { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="search"],
.auth-card select,
.auth-card textarea {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  background: var(--bg); outline: none;
}
.auth-card input:focus, .auth-card textarea:focus, .auth-card select:focus { border-color: var(--accent); }
.auth-card input[type="file"] { font-size: 13px; }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; }
  .search { order: 3; max-width: none; width: 100%; }
}
