/* =============================================================
   ĐỔI THƯƠNG HIỆU: màu nhấn sửa ở HAI chỗ (đánh dấu bên dưới),
   font sửa ở MỘT dòng (--app-font). Không rải mã màu ở chỗ khác.
   ============================================================= */

:root {
  color-scheme: light;

  /* ===== FONT ===== */
  --app-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* ===== MÀU NHẤN, CHỖ 1/2: NỀN SÁNG ===== */
  --primary: #181818;
  --primary-hover: #2e2e2e;
  --primary-foreground: #ffffff;

  --background: #f4f4f6;
  --surface: #ffffff;
  --surface-overlay: #ffffff;
  --foreground: #2c2c2c;
  --muted: #707070;
  --border: #eeeef0;
  --border-strong: #e4e4e7;
  --item-hover: #f4f4f6;
  --secondary: #e7e8ec;
  --secondary-hover: #dbdce2;
  --button-hover: #f1f1f3;
  --ring-focus: rgba(24, 24, 24, 0.1);
  --border-focus: var(--primary);

  --elevation-popover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --elevation-modal: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --segment-track: inset 0 0 0 1px rgb(0 0 0 / 0.05), inset 0 1px 2px rgb(0 0 0 / 0.04);
  --segment-thumb: 0 0 0 1px rgb(0 0 0 / 0.04), 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 6px -2px rgb(0 0 0 / 0.08);

  /* Tag phân loại bài chia sẻ */
  --tag-post-bg: #f4f4f5;    --tag-post: #52525c;
  --tag-project-bg: #ecfdf5; --tag-project: #007a55;
  --tag-link-bg: #fffbeb;    --tag-link: #bb4d00;
  --tag-photo-bg: #fdf2f8;   --tag-photo: #a3004c;
  --tag-diy-bg: #eff6ff;     --tag-diy: #1447e6;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

:root.dark {
  color-scheme: dark;

  /* ===== MÀU NHẤN, CHỖ 2/2: NỀN TỐI ===== */
  --primary: #e9edf5;
  --primary-hover: #cfd5e0;
  --primary-foreground: #05060f;

  --background: #05060f;
  --surface: #0f111a;
  --surface-overlay: #171a26;
  --foreground: #e9edf5;
  --muted: #8b93a7;
  --border: rgba(160, 180, 220, 0.12);
  --border-strong: rgba(160, 180, 220, 0.16);
  --item-hover: rgb(255 255 255 / 0.05);
  --secondary: rgb(255 255 255 / 0.08);
  --secondary-hover: rgb(255 255 255 / 0.13);
  --button-hover: rgb(255 255 255 / 0.08);
  --ring-focus: rgba(233, 237, 245, 0.12);
  --border-focus: rgba(233, 237, 245, 0.42);

  --elevation-popover: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  --elevation-modal: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.6);
  --segment-track: inset 0 0 0 1px var(--border), inset 0 1px 2px rgb(0 0 0 / 0.4);
  --segment-thumb: 0 0 0 1px var(--border-strong), inset 0 1px 0 rgb(255 255 255 / 0.06), 0 1px 2px rgb(0 0 0 / 0.5);

  --tag-post-bg: rgb(113 113 123 / 0.15);  --tag-post: #9f9fa9;
  --tag-project-bg: rgb(0 188 125 / 0.15); --tag-project: #00d492;
  --tag-link-bg: rgb(254 154 0 / 0.15);    --tag-link: #ff8904;
  --tag-photo-bg: rgb(246 51 154 / 0.15);  --tag-photo: #fb64b6;
  --tag-diy-bg: rgb(43 127 255 / 0.15);   --tag-diy: #51a2ff;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--app-font);
  font-size: 14px;
  line-height: 1.6;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }

/* Thanh cuộn tự ẩn */
* { --scrollbar-thumb: transparent; }
*:hover { --scrollbar-thumb: color-mix(in srgb, var(--foreground) 16%, transparent); }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 9999px; }
.scrollbar-clean { scrollbar-width: none; }
.scrollbar-clean::-webkit-scrollbar { display: none; }

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--background) 80%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--button-hover); }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--muted);
}
.btn-icon:hover { background: var(--item-hover); color: var(--foreground); }
.btn:focus-visible, .segment button:focus-visible, .card:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ---------- Profile ---------- */
.profile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cover {
  height: 140px;
  background: var(--secondary);
  position: relative;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgb(0 0 0 / 0.25));
}
.profile-body { padding: 0 16px 20px; }
.profile-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: -40px;
  position: relative;
  z-index: 1;
}
.avatar {
  width: 88px; height: 88px;
  border-radius: 9999px;
  border: 4px solid var(--surface);
  background: var(--primary);
  color: var(--primary-foreground);
  display: grid; place-items: center;
  font-size: 28px; font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.profile-name {
  margin-top: 16px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.profile-role { margin-top: 4px; font-size: 15px; color: var(--foreground); font-weight: 500; }
.profile-meta {
  margin-top: 8px;
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  color: var(--muted);
  font-size: 13px;
}
.profile-meta span { display: inline-flex; align-items: center; gap: 6px; }
.profile-bio { margin-top: 16px; max-width: 75ch; color: var(--foreground); }

.profile-foot {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 16px;
}
.label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 28px;
  padding: 0 10px;
  display: inline-flex; align-items: center;
  border-radius: 9999px;
  background: var(--item-hover);
  font-size: 12px; font-weight: 500;
}
.stats { display: flex; gap: 24px; flex-wrap: wrap; }
.stat-value { font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ---------- Shares ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.section-title { font-size: 18px; font-weight: 600; line-height: 1.3; }
.section-title small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 6px; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar > * { min-width: 0; }

.segment {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--secondary);
  box-shadow: var(--segment-track);
  overflow-x: auto;
  max-width: 100%;
}
.segment button {
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color .15s ease, background-color .15s ease;
}
.segment button:hover { color: var(--foreground); }
.segment button[aria-selected="true"] {
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--segment-thumb);
}
.segment .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.search { position: relative; flex: 1 1 220px; max-width: 320px; margin-left: auto; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px var(--ring-focus); }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.grid > * { min-width: 0; }

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease;
}
.card:hover { border-color: var(--border-strong); }
.card-media {
  aspect-ratio: 16 / 9;
  background: var(--item-hover);
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
}
.card:hover .card-media img { transform: scale(1.03); }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title {
  font-size: 16px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-summary {
  color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot {
  margin-top: auto;
  padding-top: 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.card-foot .tags { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-foot .icon { width: 14px; height: 14px; }

.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.badge {
  height: 22px;
  padding: 0 8px;
  display: inline-flex; align-items: center;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
}
.badge-bai-viet { background: var(--tag-post-bg); color: var(--tag-post); }
.badge-du-an    { background: var(--tag-project-bg); color: var(--tag-project); }
.badge-link     { background: var(--tag-link-bg); color: var(--tag-link); }
.badge-anh      { background: var(--tag-photo-bg); color: var(--tag-photo); }
.badge-diy      { background: var(--tag-diy-bg); color: var(--tag-diy); }

/* ---------- Empty ---------- */
.empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 16px;
  text-align: center;
  display: grid; justify-items: center; gap: 8px;
}
.empty-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--item-hover); color: var(--muted);
  display: grid; place-items: center;
  margin-bottom: 4px;
}
.empty-title { font-size: 16px; font-weight: 600; }
.empty p { color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ---------- Modal ---------- */
.modal {
  width: min(640px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--elevation-modal);
  overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: modal-in .18s cubic-bezier(.2,.7,.2,1); }
.modal::backdrop { background: rgb(5 6 15 / 0.45); animation: fade-in .18s ease; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-scroll { overflow-y: auto; }
.modal-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.modal-body { padding: 20px; display: grid; gap: 12px; }
.modal-title { font-size: 20px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }
.modal-content { white-space: pre-line; max-width: 75ch; }
.modal-tags { font-size: 12px; color: var(--muted); }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Footer ---------- */
.footer {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: 12px;
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
  .container { padding: 24px; gap: 32px; }
  .topbar-inner { padding: 0 24px; }
  .footer { padding: 24px 24px 48px; }
  .cover { height: 200px; }
  .profile-body { padding: 0 24px 24px; }
  .profile-top { margin-top: -48px; }
  .avatar { width: 104px; height: 104px; font-size: 32px; }
  .profile-name { font-size: 30px; }
  .profile-foot { grid-template-columns: 1fr auto; align-items: end; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .card-body { padding: 20px; }
}
@media (min-width: 960px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  .search { max-width: none; margin-left: 0; flex-basis: 100%; }
  .profile-top { flex-direction: column; align-items: flex-start; }
  .profile-actions { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .profile-actions .btn { height: 44px; min-width: 0; padding: 0 10px; gap: 6px; }
  .profile-actions .btn-primary { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}
