:root {
  --ink: #0b1220;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --ok: #15803d;
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 0.85em; background: #e2e8f0; padding: 0.1rem 0.35rem; border-radius: 4px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.topbar nav { display: flex; gap: 0.9rem; align-items: center; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff !important;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
}
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.9rem; }
.btn-danger { background: var(--danger); }
button.btn { font: inherit; }

.landing { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 2rem; }
.hero {
  max-width: 36rem;
  text-align: center;
  background: linear-gradient(160deg, #ffffff 0%, #e0f2fe 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2.5rem 1.75rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-size: 0.75rem; margin: 0; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0.4rem 0 0.6rem; }
.lede { color: var(--muted); margin-bottom: 1.4rem; }

.warn, .error { color: var(--danger); }
.ok { color: var(--ok); }
.muted { color: var(--muted); }

.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}
.app-layout.single { grid-template-columns: 1fr; }
.side, .panel, .main-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.side { padding: 1rem; height: fit-content; }
.main-panel { padding: 1rem; display: grid; gap: 1rem; background: transparent; border: 0; }
.panel { padding: 1rem; }
.panel-inset { background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: 0.85rem; margin-bottom: 0.75rem; }

.page-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.page-list li { margin-bottom: 0.35rem; }
.page-list li.active a { font-weight: 700; }

.stack { display: grid; gap: 0.55rem; margin: 0.75rem 0; }
.stack label { display: grid; gap: 0.25rem; font-size: 0.92rem; }
.inline {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.5rem !important;
  width: fit-content;
  max-width: 100%;
}
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.row-form { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: #fff;
}
input[type="checkbox"],
input[type="radio"],
input[type="color"],
input[type="file"] {
  width: auto;
  padding: 0;
  border-radius: 4px;
}
input[type="checkbox"],
input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  min-width: 1.05rem;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="color"] {
  width: 2.5rem;
  height: 2rem;
  padding: 0.15rem;
  cursor: pointer;
}

.thumb { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.thumb-wide { width: 100%; max-height: 140px; object-fit: cover; border-radius: 10px; }

.link-editor { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.8rem; }
.link-editor li { border-top: 1px solid var(--line); padding-top: 0.8rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 0.55rem 0.35rem; text-align: left; vertical-align: middle; }
.inline-form { display: inline; }

.feature-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
  margin: 0.5rem 0;
  background: #fff;
}
.feature-box legend {
  padding: 0 0.4rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}
.feature-list {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.feature-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  gap: 0.65rem !important;
  width: 100% !important;
  max-width: 100%;
  margin: 0 !important;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.35;
  cursor: pointer;
  background: #f8fafc;
  border: 1px solid transparent;
  box-sizing: border-box;
}
.feature-item:hover {
  border-color: var(--line);
  background: #f1f5f9;
}
.feature-item input[type="checkbox"] {
  margin-top: 0.15rem;
}
.feature-item .feature-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.feature-item .feature-label {
  font-weight: 600;
  color: var(--ink);
}
.feature-item .feature-help {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.4rem;
}
.feature-grid .feature-item {
  align-items: center !important;
  padding: 0.45rem 0.55rem;
}

.center-msg { min-height: 70vh; display: grid; place-content: center; text-align: center; gap: 0.5rem; }

/* Public bio */
.page-bio { background: #000; }
.bio-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 2rem 1rem 5rem;
  position: relative;
}
.bio-card { width: min(420px, 100%); text-align: center; }
.bio-avatar {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 0.9rem; display: grid; place-items: center;
  border: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
}
.bio-avatar.placeholder {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 2rem; font-weight: 700;
}
.bio-card h1 { margin: 0 0 0.4rem; font-size: 1.45rem; }
.bio-text { opacity: 0.85; margin: 0 0 1.2rem; }

.bio-blocks { display: grid; gap: 0.75rem; margin-top: 0.4rem; }
.bio-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.bio-link:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--accent) 28%, transparent); }
.bio-link.style-card {
  flex-direction: column;
  padding: 1.1rem 1rem;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 12%, #000);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.bio-link.style-compact {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.92rem;
  background: transparent;
  border-color: color-mix(in srgb, var(--text) 35%, transparent);
}

.bio-media { margin: 0; }
.bio-media img {
  width: 100%;
  border-radius: 14px;
  display: block;
  object-fit: cover;
  max-height: 320px;
}
.bio-media figcaption,
.media-caption {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  opacity: 0.85;
}
.video-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.music-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #0b1220;
  background: color-mix(in srgb, var(--accent) 85%, #fff);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.music-fab.is-playing { background: #fff; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}
.media-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: #f8fafc;
}
.media-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin-bottom: 0.4rem;
}
.media-card .copy-url {
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
}

.upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.35rem 0 0.15rem;
  min-height: 0;
}
.upload-preview[hidden] {
  display: none !important;
}
.upload-preview.is-loading::after {
  content: "Đang tải preview…";
  font-size: 0.85rem;
  color: var(--muted);
  align-self: center;
}
.upload-preview img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #e2e8f0;
  display: block;
}
.upload-preview.upload-preview-wide img {
  width: 100%;
  max-width: 320px;
  height: 140px;
}
.upload-preview.upload-preview-round img {
  border-radius: 50%;
}

@media (max-width: 800px) {
  .app-layout { grid-template-columns: 1fr; }
  .bio-shell { background-attachment: scroll; }
}
