:root {
  --bg: #14101a;
  --panel: #1e1726;
  --panel-2: #271d31;
  --ink: #f4eef7;
  --muted: #9c8fb0;
  --berry: #ff4d8d;
  --lime: #b6f24d;
  --blue: #5aa9ff;
  --amber: #ffb84d;
  --line: #33283f;
  --radius: 14px;
  --sidebar: 220px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 700px at 85% -10%, #2a1430 0%, var(--bg) 55%);
  color: var(--ink);
  min-height: 100vh;
}
a { color: var(--berry); }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: #16121d; border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.sb-brand { font-size: 20px; font-weight: 800; padding: 6px 8px 16px; }
.sb-brand .live { color: var(--berry); }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
}
.nav-item .ico { font-size: 17px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active { background: linear-gradient(90deg, #3a1c36, #271d31); color: var(--ink); box-shadow: inset 3px 0 0 var(--berry); }
.sb-foot { font-size: 12px; color: var(--muted); padding: 8px; }
.sb-status { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.sb-lang { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.sb-lang .ico { font-size: 15px; }
.sb-lang select { flex: 1; padding: 7px 9px; font-size: 13px; }

.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: rgba(20,16,26,.7); backdrop-filter: blur(8px); z-index: 5;
}
.page-title { font-size: 18px; font-weight: 700; }
/* Comfortable centered content width — fills 1080p, stays balanced (not stretched
   thin) on 1440p+. 1100 was left-pinned/narrow; 2200 was too sparse. */
.page { padding: 24px 28px; max-width: 1600px; width: 100%; margin: 0 auto; }

.badge { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); }
.badge.ok { color: var(--lime); }
.badge.muted { color: var(--muted); }
.topbar .acct { display: flex; gap: 10px; align-items: center; }

/* ---------- components ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.panel h3 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* Studio 3-column layout (#347): video ｜ events ｜ co-host */
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; align-items: start; }
#studioTabs { grid-column: 1 / -1; }
@media (min-width: 1101px) {
  #studioTabs { display: none !important; }
  #videoCol.tab-hidden, #eventsCol.tab-hidden { display: flex !important; }   /* wide: always show both */
}
@media (max-width: 1100px) {
  .grid3 { grid-template-columns: 1fr; }
  #studioTabs { display: flex !important; }
  #videoCol.tab-hidden, #eventsCol.tab-hidden { display: none !important; }
}
/* Inline per-event viewer intel (#347) */
.evt .body { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.vintel { font-size: 11px; color: var(--muted); background: #00000026; border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.vintel.vt-top { color: #ffd24d; background: rgba(255, 210, 77, .14); }
.vintel.vt-generous { color: #ff9ecf; background: rgba(255, 77, 141, .14); }
.evt.hi { background: linear-gradient(90deg, rgba(255, 210, 77, .09), var(--panel-2) 60%); }
/* 🔥 注目の視聴者 now rail */
.hot-rail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 2px 2px 10px; }
.hot-rail .hot-lbl { font-size: 11px; color: var(--muted); font-weight: 700; margin-right: 2px; }
.hot-chip { font-size: 11px; border: 0; border-radius: 999px; padding: 3px 9px; cursor: pointer; background: #262b3f; color: #cdd2e5; }
.hot-chip.vt-top { background: rgba(255, 210, 77, .18); color: #ffd24d; }
.hot-chip.vt-generous { background: rgba(255, 77, 141, .18); color: #ff9ecf; }
.hint { color: var(--muted); font-size: 12px; }

input, select, button { font: inherit; }
input, select { background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 11px 13px; font-size: 14px; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 14px; background: var(--panel-2); color: var(--ink); }
button.primary { background: var(--berry); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.primary.connected { background: #6b3450; }
button.ghost { background: transparent; border: 1px solid var(--line); }

.connect-row { display: flex; gap: 10px; }
.connect-row input { flex: 1; }
.status { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #6b6076; }
.dot.on { background: var(--lime); box-shadow: 0 0 10px var(--lime); }
.dot.warn { background: #ffb84d; box-shadow: 0 0 10px #ffb84d; }   /* connecting / waiting */
.room-info { margin-left: auto; font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 14px 6px; text-align: center; }
.stat span { display: block; font-size: 22px; font-weight: 800; }
.stat label { font-size: 11px; color: var(--muted); }

.toggle { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 14px; }
.toggle input { width: 16px; height: 16px; accent-color: var(--berry); }
.field { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.field label { min-width: 84px; color: var(--muted); font-size: 13px; }
.field select, .field input { flex: 1; }

.overlay-link { display: flex; gap: 8px; margin-bottom: 8px; }
.overlay-link input { flex: 1; font-size: 12px; color: var(--muted); }

.feed-list { flex: 1; overflow-y: auto; max-height: 72vh; display: flex; flex-direction: column; gap: 8px; }
.evt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 10px; background: var(--panel-2); animation: pop .25s ease; }
.evt .who { font-weight: 700; }
.evt .what { color: var(--muted); }
.evt.gift { border-left: 3px solid var(--berry); }
.evt.follow { border-left: 3px solid var(--lime); }
.evt.comment { border-left: 3px solid var(--blue); }
.evt.share { border-left: 3px solid var(--amber); }
.evt.join { opacity: .8; }
.evt .tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #00000033; color: var(--muted); margin-left: auto; }
/* Watch-on-TikTok link (#343) — replaces the embedded video panel */
.watch-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700;
  text-decoration: none; color: #fff; background: var(--berry); padding: 5px 12px; border-radius: 999px;
  white-space: nowrap; transition: filter .15s; }
.watch-link:hover { filter: brightness(1.1); }
/* Event-feed color legend (#340) */
.feed-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 4px 10px; font-size: 11px; color: var(--muted); }
.feed-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.feed-legend .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* overlay manager cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 15px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.card .desc { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.card .preview { height: 120px; border-radius: 10px; background: #0d0a12 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Crect width='10' height='10' fill='%23161320'/%3E%3Crect x='10' y='10' width='10' height='10' fill='%23161320'/%3E%3C/svg%3E"); overflow: hidden; position: relative; margin-bottom: 12px; border: 1px solid var(--line); }
.card .preview iframe { width: 200%; height: 240px; border: 0; transform: scale(.5); transform-origin: top left; }
.row-actions { display: flex; gap: 8px; }
.row-actions button, .row-actions a.btn { flex: 1; text-align: center; text-decoration: none; }
a.btn { display: inline-block; padding: 10px 14px; border-radius: 10px; background: var(--panel-2); color: var(--ink); font-weight: 600; font-size: 14px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  /* Sidebar becomes a fixed bottom tab bar (icons + labels). */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: auto;
    flex-direction: row; flex-wrap: nowrap; justify-content: space-around;
    gap: 2px; padding: 4px 2px env(safe-area-inset-bottom, 4px); z-index: 40;
    border-top: 1px solid var(--border, #2a2f45); background: var(--panel, #161922);
  }
  .sb-brand, .sb-foot, .sb-status, .sb-lang, .cmdk-open { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 10px; text-align: center; min-width: 0; }
  .nav-item .ico { font-size: 20px; width: auto; }
  .nav-item.active { box-shadow: inset 0 3px 0 var(--berry); }
  .content { padding-bottom: 64px; }
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}

/* ⌘K command palette */
.cmdk-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding-top: 12vh; }
.cmdk-bg.show { display: flex; }
.cmdk { background: var(--panel, #161922); border: 1px solid var(--border, #2a2f45); border-radius: 12px; width: 92%; max-width: 520px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.cmdk input { width: 100%; border: 0; border-bottom: 1px solid var(--border, #2a2f45); background: transparent; color: var(--ink, #e8e8f0); padding: 14px 16px; font-size: 16px; outline: none; box-sizing: border-box; }
.cmdk-list { max-height: 340px; overflow-y: auto; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; font-size: 14px; }
.cmdk-item.sel { background: var(--panel-2, #1a1d2b); box-shadow: inset 3px 0 0 var(--berry, #ff4d8d); }
.cmdk-item .ico { font-size: 16px; width: 20px; text-align: center; }
.cmdk-hint { padding: 8px 16px; font-size: 11px; color: var(--muted, #9aa0b4); border-top: 1px solid var(--border, #2a2f45); display: flex; justify-content: space-between; }
