:root {
  --bg-base: #0b0d12;
  --bg-raised: #12151c;
  --bg-subtle: #181c24;
  --bg-hover: #1d222c;
  --border: #272c37;
  --border-strong: #363d4b;
  --accent-primary: #6ea8fe;
  --accent-soft: #182a46;
  --accent-contrast: #07101f;
  --success: #43c98c;
  --danger: #ff6b7a;
  --text-primary: #f2f4f8;
  --text-secondary: #a7afbd;
  --text-muted: #87909f;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.42);
  --font-main: "IBM Plex Sans", "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="emerald-aurora"] { --accent-primary: #5ed6a1; --accent-soft: #122d25; --accent-contrast: #071710; }
[data-theme="obsidian-gold"] { --accent-primary: #e8be63; --accent-soft: #332918; --accent-contrast: #191105; }
[data-theme="sunset-vibe"] { --accent-primary: #f39178; --accent-soft: #38201f; --accent-contrast: #1b0d0a; }
[data-theme="midnight-mono"] { --accent-primary: #f2f4f8; --accent-soft: #262a32; --accent-contrast: #0b0d12; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.5;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--accent-primary) 9%, transparent), transparent 30rem), var(--bg-base);
  padding: var(--safe-top) 24px var(--safe-bottom);
}

button, input, select, textarea { font: inherit; }
::selection { color: var(--text-primary); background: color-mix(in srgb, var(--accent-primary) 38%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 3px solid var(--bg-base); border-radius: 10px; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [role="link"]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
}

.ambient-bg, .bg-grid { display: none; }

.app-container {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  column-gap: clamp(36px, 6vw, 88px);
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 104px;
}

.top-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.top-bar-left, .top-bar-right { display: flex; align-items: center; gap: 8px; }

.glass-btn, .glass-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.glass-btn:hover, .glass-btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); border-color: var(--border-strong); }
.glass-btn:active, .glass-btn-icon:active { background: var(--bg-subtle); }
.glass-btn-icon { width: 40px; padding: 0; }

.ph, .ph-fill { display: block; flex: 0 0 auto; line-height: 1; }

.live-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pulse-dot, .status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--success); }

.profile-card {
  grid-column: 1;
  grid-row: 2 / 4;
  align-self: start;
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: clamp(46px, 7vw, 76px) 0 24px;
  text-align: left;
}

.avatar-wrapper { position: relative; width: 112px; height: 112px; margin-bottom: 26px; cursor: pointer; user-select: none; }
.avatar-ring { position: absolute; inset: -5px; border: 1px solid color-mix(in srgb, var(--accent-primary) 70%, var(--border)); border-radius: 22px; }
.avatar-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-subtle);
  border-radius: 18px;
  filter: saturate(0.9) contrast(1.03);
  transition: filter 180ms ease;
}
.avatar-wrapper:hover .avatar-img { filter: saturate(1) contrast(1.04); }
.status-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  z-index: 2;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.status-dot { width: 10px; height: 10px; }

.profile-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.profile-name { color: var(--text-primary); font-size: clamp(30px, 4vw, 40px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; }
.verified-icon { display: flex; color: var(--accent-primary); }
.profile-handle { margin-bottom: 20px; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.profile-status-text { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.profile-status-text .pulse-dot { width: 7px; height: 7px; }
.profile-bio { max-width: 34ch; margin-bottom: 24px; color: var(--text-secondary); font-size: 15px; line-height: 1.7; }

.social-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.social-btn {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--text-secondary);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}
.social-btn:hover { color: var(--accent-primary); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent-primary) 50%, var(--border)); }

.action-grid { display: flex; flex-direction: column; width: 100%; border-top: 1px solid var(--border); }
.action-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 0;
  color: var(--text-secondary);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: color 160ms ease;
}
.action-card:hover { color: var(--text-primary); }
.action-card:hover .action-icon-wrap { color: var(--accent-primary); }
.action-icon-wrap { display: grid; width: 28px; height: 28px; place-items: center; color: var(--text-muted); transition: color 160ms ease; }

.category-tabs {
  grid-column: 2;
  display: flex;
  gap: 4px;
  align-self: end;
  overflow-x: auto;
  padding: clamp(48px, 7vw, 78px) 0 16px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-pill {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 11px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 160ms ease, background-color 160ms ease;
}
.cat-pill:hover { color: var(--text-primary); background: var(--bg-raised); }
.cat-pill.active { color: var(--text-primary); background: var(--bg-subtle); }

.links-list { grid-column: 2; display: flex; flex-direction: column; width: 100%; }
.link-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 88px;
  padding: 18px 6px;
  color: var(--text-primary);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  transition: background-color 160ms ease;
}
.link-card:hover, .link-card.featured:hover { background: var(--bg-raised); }
.link-card.featured { background: transparent; border: 0; border-bottom: 1px solid var(--border); box-shadow: none; }
.link-card.featured::before { display: none; }
.link-icon-wrap { display: grid; width: 42px; height: 42px; place-items: center; color: var(--text-secondary); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 10px; }
.link-card.featured .link-icon-wrap { color: var(--accent-primary) !important; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent-primary) 34%, var(--border)); }
.link-content { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; }
.link-title-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.link-title { overflow: hidden; color: var(--text-primary); font-size: 15px; font-weight: 600; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.link-badge { flex: 0 0 auto; padding: 2px 7px; color: var(--text-primary); background: var(--bg-subtle) !important; border: 1px solid var(--border-strong); border-radius: 5px; font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.link-subtitle { overflow: hidden; color: var(--text-muted); font-size: 13px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.link-actions { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.link-action-btn { display: grid; width: 36px; height: 36px; min-width: 36px; place-items: center; color: var(--text-muted); background: transparent; border: 0; border-radius: var(--radius-sm); cursor: pointer; transition: color 160ms ease, background-color 160ms ease; }
.link-action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.click-counter { min-width: 24px; color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: center; }

.audio-dock {
  position: fixed;
  right: 24px;
  bottom: calc(var(--safe-bottom) + 24px);
  z-index: 10;
  display: flex;
  align-items: stretch;
  width: min(360px, calc(100% - 48px));
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
  background: #141820;
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.audio-dock.hidden { display: none !important; }
.audio-dock-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audio-dock-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.audio-play-btn { display: grid; flex: 0 0 auto; width: 36px; height: 36px; place-items: center; color: var(--accent-contrast); background: var(--accent-primary); border: 0; border-radius: 9px; cursor: pointer; }
.audio-dock.youtube-source .audio-play-btn { color: #fff; background: #ff0033; }
.audio-dock.youtube-source .equalizer { display: none; }
.audio-meta { display: flex; flex-direction: column; min-width: 0; }
.audio-title, .audio-artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-title { color: var(--text-primary); font-size: 12.5px; font-weight: 600; }
.audio-artist { color: var(--text-muted); font-size: 11px; }
.equalizer { display: flex; align-items: flex-end; gap: 3px; height: 16px; padding: 0 5px; }
.eq-bar { width: 2px; height: 4px; background: var(--accent-primary); border-radius: 2px; }
.audio-dock.playing .eq-bar:nth-child(1) { animation: eqJump 0.8s ease infinite alternate; }
.audio-dock.playing .eq-bar:nth-child(2) { animation: eqJump 0.6s ease infinite 0.2s alternate; }
.audio-dock.playing .eq-bar:nth-child(3) { animation: eqJump 1.1s ease infinite 0.4s alternate; }
.audio-dock.playing .eq-bar:nth-child(4) { animation: eqJump 0.7s ease infinite 0.1s alternate; }
@keyframes eqJump { from { height: 3px; } to { height: 16px; } }
.youtube-player-panel.hidden { display: none; }
.youtube-player-panel { overflow: hidden; width: 100%; height: 200px; background: #000; border-radius: 9px; }
.youtube-player-panel iframe { display: block; width: 100%; height: 200px; border: 0; }

.footer-section { grid-column: 2; padding: 28px 0; color: var(--text-muted); font-size: 12px; }

.toast-container { position: fixed; top: calc(var(--safe-top) + 20px); left: 50%; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100% - 32px)); transform: translateX(-50%); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 14px; color: var(--text-primary); background: #171b23; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36); font-size: 13px; font-weight: 500; animation: toastIn 220ms cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.modal-overlay { position: fixed; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center; padding: 20px; visibility: hidden; opacity: 0; background: rgba(2, 4, 8, 0.78); transition: opacity 180ms ease, visibility 180ms ease; }
.modal-overlay.active { visibility: visible; opacity: 1; }
.bottom-sheet { width: min(460px, 100%); max-height: min(760px, 90vh); overflow-y: auto; padding: 22px; background: var(--bg-raised); border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); transform: translateY(10px) scale(0.99); transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1); }
.modal-overlay.active .bottom-sheet { transform: translateY(0) scale(1); }
.sheet-handle { display: none; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.sheet-title { color: var(--text-primary); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.sheet-close-btn { display: grid; flex: 0 0 auto; width: 36px; height: 36px; place-items: center; color: var(--text-secondary); background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.sheet-close-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 18px; color: var(--text-secondary); text-align: center; }
.qr-canvas-wrap { display: inline-grid; place-items: center; padding: 14px; background: #fff; border-radius: var(--radius-md); }
.vietqr-card { display: flex; flex-direction: column; gap: 12px; padding: 15px; background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius-md); }
.bank-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; font-size: 13.5px; }
.bank-label { color: var(--text-muted); }
.bank-val { display: flex; align-items: center; gap: 4px; color: var(--text-primary); font-weight: 600; text-align: right; }

@media (max-width: 760px) {
  body { padding-right: 18px; padding-left: 18px; }
  .app-container { display: flex; max-width: 580px; min-height: 100vh; flex-direction: column; }
  .top-bar { min-height: 64px; }
  .profile-card { position: static; padding: 42px 0 20px; }
  .avatar-wrapper { width: 104px; height: 104px; margin-bottom: 24px; }
  .profile-bio { max-width: 46ch; }
  .action-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 0; gap: 8px; }
  .action-card { display: flex; min-width: 0; min-height: 78px; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md); line-height: 1.25; }
  .category-tabs { align-self: stretch; margin-right: -18px; margin-left: -18px; padding: 18px 18px 12px; }
  .links-list { align-self: stretch; }
  .footer-section { text-align: left; }
}

@media (max-width: 520px) {
  .live-status-pill { max-width: 180px; }
  .live-status-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-bar-right { gap: 5px; }
  .glass-btn-icon { width: 38px; min-height: 38px; }
  .link-card { grid-template-columns: 40px minmax(0, 1fr) 36px; gap: 12px; min-height: 82px; }
  .link-actions .click-counter, .link-actions .copy-btn { display: none; }
  .link-subtitle { display: -webkit-box; overflow: hidden; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .bottom-sheet { padding: 20px; }
  .audio-dock { right: 16px; bottom: calc(var(--safe-bottom) + 16px); width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
