:root {
  --bg: #121417;
  --panel: #1b1f26;
  --panel-2: #222834;
  --panel-3: #0f1319;
  --text: #eef3ff;
  --muted: #8e9ab2;
  --line: #2d3544;
  --blue: #59a6ff;
  --green: #29c46d;
  --red: #ef4d64;
  --purple: #b36cff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --radius-sm: 10px;
}

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

html,
body,
#root {
  width: 100%;
  height: 100%;
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
  background:
    radial-gradient(circle at top left, rgba(89, 166, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(179, 108, 255, 0.1), transparent 24%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

body.overlay-mode {
  background: transparent;
}

.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(19, 24, 31, 0.85);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(89, 166, 255, 0.25), rgba(179, 108, 255, 0.3)),
    #1f2632;
  box-shadow: var(--shadow);
  font-size: 18px;
  flex: 0 0 auto;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}

.tab-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-button {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: 0.18s ease;
}

.tab-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab-button.is-active {
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(89, 166, 255, 0.18), rgba(179, 108, 255, 0.16)),
    rgba(255, 255, 255, 0.02);
  border-color: rgba(89, 166, 255, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.page-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.page-scroll {
  height: 100%;
  overflow: auto;
  padding: 18px;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 80%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.panel-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1 1 340px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: 0.18s ease;
}

.text-input:focus {
  border-color: rgba(89, 166, 255, 0.4);
  box-shadow: 0 0 0 4px rgba(89, 166, 255, 0.12);
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 12px 16px;
  color: white;
  font-size: 13px;
  font-weight: 800;
  transition: 0.18s ease;
  min-height: 44px;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #3e94ff, #5c70ff);
}

.btn-success {
  background: linear-gradient(135deg, #22b861, #2ccb78);
}

.btn-danger {
  background: linear-gradient(135deg, #e34b62, #ff5b7e);
}

.btn-toggle {
  min-width: 110px;
  letter-spacing: 0.02em;
}

.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
  min-height: 44px;
  padding: 0 4px;
}

.switch-state {
  min-width: 52px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}

.switch-state.is-on {
  background: rgba(239, 77, 100, 0.12);
  color: #ff9dae;
  border-color: rgba(239, 77, 100, 0.24);
}

.switch-state.is-off {
  background: rgba(41, 196, 109, 0.12);
  color: #86f1b1;
  border-color: rgba(41, 196, 109, 0.24);
}

.status-card {
  margin: 0 16px 16px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-card.success {
  background: rgba(41, 196, 109, 0.1);
  color: #86f1b1;
  border-color: rgba(41, 196, 109, 0.25);
}

.status-card.error {
  background: rgba(239, 77, 100, 0.12);
  color: #ff9daa;
  border-color: rgba(239, 77, 100, 0.26);
}

.status-card.info {
  background: rgba(89, 166, 255, 0.1);
  color: #abd1ff;
  border-color: rgba(89, 166, 255, 0.22);
}

.viewer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.95fr);
  gap: 16px;
  min-height: 0;
  padding: 0 16px 16px;
}

.stack-col {
  display: grid;
  gap: 16px;
  min-height: 0;
}

.history-list,
.gift-list {
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.history-item,
.gift-item {
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  animation: fadeUp 0.22s ease-out;
}

.history-item:last-child,
.gift-item:last-child {
  margin-bottom: 0;
}

.comment-top,
.gift-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.comment-user,
.gift-user {
  font-size: 13px;
  font-weight: 800;
  color: var(--blue);
}

.gift-user {
  color: #f0a8ff;
}

.comment-time,
.gift-time {
  font-size: 11px;
  color: var(--muted);
}

.comment-text,
.gift-text {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.gift-item {
  background:
    linear-gradient(135deg, rgba(179, 108, 255, 0.14), transparent 65%),
    rgba(255, 255, 255, 0.02);
  border-color: rgba(179, 108, 255, 0.22);
}

.empty-state {
  height: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
}

.mini-grid {
  display: grid;
  grid-template-rows: minmax(220px, 0.85fr) minmax(240px, 1fr);
  gap: 16px;
  min-height: 0;
}

.iframe-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #0a0d11;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.iframe-preview {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.iframe-connector-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: -9999px;
  border: none;
}

.iframe-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

.stream-info {
  margin: 0 16px 16px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.stream-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}

.stream-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.stream-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat-pill {
  min-width: 86px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  text-align: center;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--blue);
}

.live-pill {
  padding: 10px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid transparent;
}

.live-pill.live {
  background: rgba(239, 77, 100, 0.12);
  color: #ff9dae;
  border-color: rgba(239, 77, 100, 0.25);
}

.live-pill.offline {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.06);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 1.8s infinite;
}

.settings-shell,
.obs-grid {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.setting-block {
  padding: 18px;
}

.setting-item {
  margin-bottom: 20px;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
}

.setting-value {
  color: var(--blue);
  white-space: nowrap;
}

.range-input {
  width: 100%;
  accent-color: #5ea8ff;
}

.preview-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(89, 166, 255, 0.08), transparent 50%),
    var(--panel-3);
}

.preview-caption {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 700;
}

.obs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.code-box {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  word-break: break-all;
  white-space: pre-wrap;
}

.help-list {
  padding-left: 20px;
  color: #c8d2e8;
  font-size: 13px;
  line-height: 1.8;
}

.help-list li + li {
  margin-top: 6px;
}

.overlay-root {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

.overlay-hidden-frame {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: -9999px;
  border: none;
}

.overlay-status {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 30;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  backdrop-filter: blur(10px);
  background: rgba(11, 15, 21, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e5edff;
  max-width: min(92vw, 560px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overlay-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.overlay-item {
  position: absolute;
  left: 22px;
  right: 22px;
  max-width: calc(100% - 44px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  min-width: min(240px, calc(100% - 44px));
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(7, 12, 18, 0.52);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  animation: overlayIn 0.22s ease-out;
  will-change: transform, opacity;
}

.overlay-badge {
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(89, 166, 255, 0.16);
  color: #d9ebff;
  flex: 0 0 auto;
}

.overlay-body {
  min-width: 0;
}

.overlay-user {
  display: inline;
  font-weight: 900;
  margin-right: 8px;
  opacity: 0.98;
}

.overlay-message {
  display: inline;
  font-weight: 800;
  opacity: 0.98;
  word-break: break-word;
}

.footer-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.small-muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.mono {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes overlayIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 100, 120, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 100, 120, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 100, 120, 0);
  }
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: #3b4658;
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1080px) {
  .viewer-grid {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    grid-template-rows: minmax(200px, auto) minmax(240px, auto);
  }

  .stream-info {
    grid-template-columns: 1fr;
  }

  .stream-stats {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .brand-sub {
    max-width: 100%;
  }

  .page-scroll {
    padding: 12px;
  }

  .viewer-grid,
  .stream-info,
  .status-card {
    margin: 0;
  }

  .viewer-grid {
    padding: 0;
  }

  .stream-info {
    margin-top: 16px;
  }

  .input-row {
    padding: 14px;
  }

  .status-card,
  .stream-info {
    margin-top: 16px;
  }
}