:root {
  color-scheme: dark;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #101214;
  color: #f4f1ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #101214;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #15181b;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d7b56d;
  color: #171717;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: #aaa39a;
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 6px;
  background: #d7b56d;
  color: #141414;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  min-height: calc(100vh - 76px);
}

.video-area {
  position: relative;
  display: grid;
  place-items: center;
  background: #070809;
}

video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 76px);
  object-fit: contain;
  background: #050607;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  background: #070809;
}

.empty-state h2 {
  font-size: 24px;
}

.empty-state p {
  color: #aaa39a;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background: #15181b;
  min-height: 0;
}

.chat-header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header span {
  color: #918b83;
  font-size: 12px;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #918b83;
  font-size: 12px;
}

#online-count {
  color: #d7b56d;
  font-weight: 700;
  white-space: nowrap;
}

.owner-layout {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
}

.owner-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.owner-stats div,
.owner-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #15181b;
}

.owner-stats div {
  padding: 18px;
}

.owner-stats span {
  display: block;
  color: #aaa39a;
  font-size: 13px;
}

.owner-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.owner-stats .is-live {
  color: #7ee0a4;
}

.owner-panel {
  min-height: 220px;
  padding: 18px;
}

.owner-chat-panel {
  grid-column: 1 / -1;
}

.owner-panel h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.owner-list {
  display: grid;
  gap: 10px;
}

.owner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.owner-row strong {
  display: block;
  color: #f4f1ec;
}

.owner-row span {
  display: block;
  margin-top: 5px;
  color: #918b83;
  font-size: 12px;
}

.owner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.owner-actions button {
  padding: 8px 10px;
}

.owner-actions button[data-action="kick"] {
  background: #ff9a8c;
}

.owner-actions button[data-action="unban"] {
  background: #7ee0a4;
}

.owner-messages {
  max-height: 360px;
  overflow-y: auto;
}

.owner-message {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.owner-message div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d7b56d;
  font-size: 13px;
}

.owner-message time {
  color: #77716b;
}

.owner-message p {
  margin-top: 6px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.owner-empty {
  color: #918b83;
}

.messages {
  overflow-y: auto;
  padding: 16px;
}

.message {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.message div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d7b56d;
  font-size: 13px;
}

.message time {
  color: #77716b;
}

.message p {
  margin-top: 6px;
  line-height: 1.5;
  color: #eee8de;
  overflow-wrap: anywhere;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #0f1113;
  color: #f4f1ec;
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: #d7b56d;
}

input:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.text-button {
  border-radius: 6px;
  background: #d7b56d;
  color: #141414;
  font-weight: 700;
  padding: 10px 16px;
  text-decoration: none;
}

.admin-layout {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 28px 20px;
  display: grid;
  gap: 18px;
}

.admin-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #15181b;
  padding: 22px;
}

.admin-panel h2 {
  margin-bottom: 18px;
  font-size: 18px;
}

.admin-panel h2:not(:first-child) {
  margin-top: 24px;
}

.admin-form {
  display: grid;
  gap: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.form-grid label {
  color: #aaa39a;
  font-size: 13px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.admin-actions button[type="button"] {
  background: #262b30;
  color: #f4f1ec;
}

.muted-panel p {
  color: #c8c1b8;
  line-height: 1.7;
}

.muted-panel p + p {
  margin-top: 8px;
}

.setting-list {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.setting-list label {
  color: #aaa39a;
  font-size: 13px;
}

.setting-list code {
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #0f1113;
  color: #f4f1ec;
  padding: 10px 12px;
  overflow-wrap: anywhere;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 28px;
  background: #15181b;
}

.brand-mark {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-error {
  margin-top: 14px;
  color: #ff9a8c;
}

@media (max-width: 900px) {
  .topbar {
    padding: 14px 16px;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(300px, 1fr);
    min-height: calc(100svh - 76px);
  }

  .chat {
    grid-template-rows: auto auto minmax(0, 1fr);
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 300px;
  }

  .video-area {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 0;
  }

  video {
    height: 100%;
    max-height: none;
  }

  .chat-header {
    grid-row: 1;
  }

  .messages {
    grid-row: 3;
    min-height: 0;
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .composer {
    grid-row: 2;
    grid-template-columns: minmax(0, 1fr) 56px;
    padding: 10px 14px 12px;
    border-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #15181b;
  }

  input {
    min-height: 42px;
    font-size: 16px;
  }

  body.chat-focus .chat {
    min-height: 260px;
  }

  .setting-list {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .owner-layout,
  .owner-stats {
    grid-template-columns: 1fr;
  }

  .owner-chat-panel {
    grid-column: auto;
  }

  .owner-row {
    grid-template-columns: 1fr;
  }

  .owner-actions {
    justify-content: flex-start;
  }
}
