* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e9e9ea;
  background: #0f0f10;
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- sidebar ---------- */
aside {
  background: #17171a;
  border-right: 1px solid #272729;
  display: flex; flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
}
.brand {
  display: grid; grid-template-columns: 36px 1fr; gap: 10px;
  align-items: center; margin-bottom: 18px;
}
.logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #ff3b5c, #25f4ee);
  color: #000; font-weight: 800; font-size: 14px;
  display: grid; place-items: center;
}
.title { font-size: 14px; font-weight: 600; }
.sub { font-size: 11px; color: #8b8b90; margin-top: 2px; }
.sub.ok { color: #25f4ee; }
.sub.err { color: #ff3b5c; }

.userbox { display: flex; gap: 6px; margin-bottom: 14px; }
#user {
  flex: 1; padding: 8px 10px;
  border: 1px solid #2d2d30; border-radius: 7px;
  background: #0f0f10; color: #e9e9ea; font: inherit;
}
#user:focus { outline: 2px solid #25f4ee; outline-offset: -1px; border-color: #25f4ee; }
.go {
  padding: 8px 12px; border: 0; border-radius: 7px;
  background: #25f4ee; color: #000; font: inherit; font-weight: 600;
  cursor: pointer;
}
.go:hover { background: #4ff7f1; }

.recents { flex: 1; overflow-y: auto; }
.recents-head {
  font-size: 10px; color: #8b8b90; text-transform: uppercase;
  letter-spacing: 0.6px; padding: 4px 10px 6px;
}
.recents ul { list-style: none; padding: 0; margin: 0; }
.recents li { padding: 0; }
.recent-item {
  width: 100%; text-align: left;
  padding: 7px 10px; border: 0; background: transparent;
  color: #d0d0d2; font: inherit; border-radius: 6px; cursor: pointer;
}
.recent-item:hover { background: #222225; color: #fff; }

footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid #272729; }
.hint { color: #6c6c70; font-size: 11px; }
.hint code { color: #c0c0c4; background: #222225; padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* ---------- main ---------- */
main { background: #0f0f10; overflow: hidden; display: flex; flex-direction: column; }
.panel { flex: 1; display: none; flex-direction: column; overflow: hidden; }
.panel.active { display: flex; }
.panel-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #1d1d20;
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-head .muted { font-size: 12px; color: #8b8b90; }
.panel-body { padding: 20px; overflow-y: auto; }
.placeholder { color: #6c6c70; padding: 24px; text-align: center; }

.error { color: #ff6b6b; background: #2a1414; padding: 10px 12px; border-radius: 7px; }

/* ---------- user card ---------- */
.user-card {
  background: #17171a; border: 1px solid #272729; border-radius: 12px;
  padding: 16px; display: grid; grid-template-columns: 80px 1fr; gap: 16px;
}
.user-card img.avatar { width: 80px; height: 80px; border-radius: 50%; background: #272729; object-fit: cover; }
.user-card .name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.user-card .handle { color: #8b8b90; margin-top: 2px; }
.user-card .bio { color: #d0d0d2; margin-top: 10px; white-space: pre-wrap; }
.user-card .stats {
  display: flex; gap: 20px; margin-top: 12px; flex-wrap: wrap;
}
.user-card .stat-item { color: #8b8b90; font-size: 12px; }
.user-card .stat-item b { color: #e9e9ea; font-size: 15px; display: block; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.v { background: #0a3b7a; color: #8cc3ff; }
.badge.p { background: #7a1818; color: #ffbcbc; }

/* ---------- stories grid ---------- */
.stories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; }
.story {
  position: relative; aspect-ratio: 9/16; background: #000;
  border-radius: 8px; overflow: hidden; border: 1px solid #272729;
}
.story img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story a { position: absolute; inset: 0; }
.story .dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 4px;
}

/* ---------- live ---------- */
.live-layout {
  flex: 1; display: grid; grid-template-columns: 1fr 340px;
  gap: 0; overflow: hidden;
}
.live-video {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
#liveVideo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}
.live-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #8b8b90; background: rgba(0,0,0,.7); font-size: 13px;
  pointer-events: none;
}
.live-overlay.hidden { display: none; }
.live-side { display: flex; flex-direction: column; border-left: 1px solid #1d1d20; background: #141416; }
.live-stats { display: flex; gap: 0; border-bottom: 1px solid #1d1d20; }
.stat { flex: 1; padding: 10px 14px; border-right: 1px solid #1d1d20; }
.stat:last-child { border-right: 0; }
.stat .lab { font-size: 10px; color: #8b8b90; text-transform: uppercase; letter-spacing: 0.5px; }
.stat .val { font-size: 16px; font-weight: 700; color: #e9e9ea; margin-top: 2px; }
.stat .val.mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; font-weight: 500; color: #c0c0c4; }

.feed { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.feed li { padding: 6px 12px; border-bottom: 1px solid #1d1d20; font-size: 12px; color: #d0d0d2; word-wrap: break-word; }
.feed li:last-child { border-bottom: 0; }
.feed .kind {
  display: inline-block; min-width: 54px; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700; margin-right: 6px; text-transform: uppercase;
  color: #000;
}
.k-comment { background: #8b8b90; color: #000; }
.k-gift { background: #ff8a3b; }
.k-like { background: #ff3b5c; color: #fff; }
.k-follow { background: #25f4ee; }
.k-join { background: #c0c0c4; }
.k-share { background: #4fe389; }
.k-viewers { background: #55aaff; color: #fff; }
.k-connect { background: #fff; }
.k-disconnect, .k-ended { background: #555; color: #fff; }
.k-error { background: #ff3b5c; color: #fff; }
.feed b { color: #fff; font-weight: 600; }

/* ---------- mobile ---------- */
.menu-btn {
  display: none;
  position: fixed; top: 10px; left: 10px; z-index: 20;
  width: 40px; height: 40px; border: 0; border-radius: 8px;
  background: #222225; color: #fff; font-size: 20px; cursor: pointer;
}
@media (max-width: 720px) {
  body { grid-template-columns: 1fr; }
  aside {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 10;
    transform: translateX(-110%); transition: transform 0.2s ease;
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
  }
  aside.open { transform: translateX(0); }
  .menu-btn { display: block; }
  main { padding-top: 56px; }
  .panel-head { padding: 12px 16px 10px; }
  .live-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(40vh, 1fr) minmax(200px, 40vh);
  }
  .live-side { border-left: 0; border-top: 1px solid #1d1d20; }
}
