:root {
  --primary: #0066cc;
  --primary-focus: #0071e3;
  --primary-dark: #2997ff;
  --ink: #1d1d1f;
  --muted: #7a7a7a;
  --dark-muted: #cccccc;
  --hairline: #e0e0e0;
  --divider: #f0f0f0;
  --canvas: #ffffff;
  --parchment: #f5f5f7;
  --pearl: #fafafc;
  --dark-1: #272729;
  --dark-2: #2a2a2c;
  --dark-3: #252527;
  --black: #000000;
  --chip: rgba(210, 210, 215, 0.64);
  --radius-sm: 8px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  --nav-h: 44px;
  --subnav-h: 64px;
  font-family: "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--parchment);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--parchment);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
  border: 0;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

button:active {
  transform: scale(0.95);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-focus);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.hidden {
  display: none !important;
}

.global-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--nav-h);
  background: var(--black);
  color: #fff;
}

.nav-inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-button {
  min-height: 32px;
  padding: 0;
  background: transparent;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

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

.nav-user {
  color: var(--dark-muted);
  font-size: 12px;
  line-height: 1;
}

.dark-utility {
  min-height: 32px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}

.auth-screen {
  min-height: calc(100vh - var(--nav-h));
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 520px);
}

.auth-copy {
  position: relative;
  overflow: hidden;
  min-height: 580px;
  padding: 80px 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--dark-1);
  color: #fff;
}

.auth-copy::after {
  content: "";
  position: absolute;
  right: 8vw;
  bottom: 72px;
  width: min(440px, 48%);
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  background: #000;
}

.auth-copy h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: "SF Pro Display", system-ui, -apple-system, sans-serif;
  font-size: 56px;
  line-height: 1.07;
  font-weight: 600;
}

.auth-copy p {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 18px 0 0;
  color: var(--dark-muted);
  font-size: 24px;
  font-weight: 300;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 12px;
  color: inherit;
  opacity: 0.68;
  font-size: 12px !important;
  line-height: 1 !important;
}

.auth-panel {
  padding: 80px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--canvas);
}

.segmented {
  min-height: 44px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--parchment);
}

.segment {
  min-height: 36px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--canvas);
  color: var(--ink);
}

.form-stack {
  margin-top: 24px;
  display: grid;
  gap: 17px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.43;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px 20px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-pill);
  background: var(--canvas);
  color: var(--ink);
}

textarea {
  min-height: 112px;
  border-radius: var(--radius-sm);
  resize: vertical;
}

.primary-pill,
.secondary-pill,
.pearl-button {
  min-height: 44px;
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.primary-pill {
  background: var(--primary);
  color: #fff;
}

.secondary-pill {
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
}

.pearl-button {
  border: 3px solid var(--divider);
  border-radius: 11px;
  background: var(--pearl);
  color: #333;
  font-size: 14px;
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sub-nav {
  position: sticky;
  top: var(--nav-h);
  z-index: 15;
  min-height: var(--subnav-h);
  padding: 10px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.sub-nav h2 {
  margin: 0;
  font-family: "SF Pro Display", system-ui, -apple-system, sans-serif;
  font-size: 21px;
  line-height: 1.19;
  font-weight: 600;
}

.tab-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tab-button {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 11px;
  background: var(--pearl);
  color: #333;
  font-size: 14px;
}

.tab-button.active {
  background: var(--primary);
  color: #fff;
}

.surface {
  min-height: calc(100vh - var(--nav-h) - var(--subnav-h));
  padding: 80px 32px;
}

.light-surface,
.admin-surface {
  background: var(--parchment);
}

.room-surface {
  background: var(--dark-3);
  color: #fff;
}

.content-grid,
.admin-grid {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.status-grid {
  width: min(1440px, 100%);
  margin: 0 auto 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-tile {
  min-height: 108px;
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  display: grid;
  align-content: space-between;
  background: var(--canvas);
}

.metric-tile span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.29;
}

.metric-tile strong {
  font-family: "SF Pro Display", system-ui, -apple-system, sans-serif;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 600;
}

.admin-grid {
  align-items: start;
}

.utility-card {
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--canvas);
  color: var(--ink);
}

.featured-card {
  min-height: 360px;
  align-content: center;
}

.room-list-card {
  min-height: 360px;
}

.card-kicker {
  color: var(--primary);
  font-size: 14px;
  line-height: 1.29;
}

.wide-card {
  grid-column: 1 / -1;
}

h3 {
  margin: 0 0 17px;
  font-size: 21px;
  line-height: 1.19;
  font-weight: 600;
}

.section-head {
  margin-bottom: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  margin: 0;
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-item {
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--divider);
}

.list-item > div:first-child {
  min-width: 0;
}

.list-item:first-child {
  border-top: 0;
}

.item-title {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.item-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.status-pill {
  width: fit-content;
  min-height: 28px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.item-meta + .status-pill {
  margin-top: 8px;
}

.status-good {
  border-color: rgba(0, 102, 204, 0.18);
  background: rgba(0, 102, 204, 0.08);
  color: var(--primary);
}

.status-warn {
  border-color: rgba(122, 122, 122, 0.22);
  background: var(--pearl);
  color: #333;
}

.status-bad {
  border-color: rgba(180, 0, 0, 0.18);
  background: #fff5f5;
  color: #9b0000;
}

.status-muted {
  border-color: rgba(0, 0, 0, 0.06);
  background: var(--pearl);
  color: var(--muted);
}

.empty-state {
  min-height: 96px;
  padding: 24px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--pearl);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.room-surface .empty-state {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--dark-2);
  color: var(--dark-muted);
}

.button-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.room-layout {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}

.player-column,
.chat-column {
  display: grid;
  gap: 17px;
  align-content: start;
}

.player-shell {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--black);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.player-shell video {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--black);
}

.danmaku-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.danmaku {
  position: absolute;
  right: -100%;
  min-width: max-content;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  font-size: 21px;
  font-weight: 600;
  animation: danmaku-slide 8s linear forwards;
}

@keyframes danmaku-slide {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100vw - 100%)); }
}

.control-strip {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.url-input {
  border-radius: var(--radius-pill);
}

.room-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--dark-muted);
  font-size: 14px;
}

.storage-browser,
.members-panel,
.chat-panel {
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--dark-1);
  color: #fff;
}

.compact-head {
  margin-bottom: 12px;
}

.storage-browser select {
  max-width: 320px;
}

.path-row,
.manager-row,
.inline-form {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.path-row span,
.manager-row span {
  color: var(--dark-muted);
  word-break: break-all;
}

.panel-note {
  min-height: 20px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.43;
}

.room-surface .panel-note {
  color: var(--dark-muted);
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.file-button {
  min-height: 68px;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
  text-align: left;
  overflow-wrap: anywhere;
}

.file-button:disabled {
  opacity: 0.38;
}

.room-surface .file-button {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--dark-2);
  color: #fff;
}

.file-button small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.room-surface .file-button small {
  color: var(--dark-muted);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-chip {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--chip);
  color: var(--ink);
  font-size: 14px;
}

.chat-messages {
  height: min(48vh, 420px);
  overflow: auto;
  padding-right: 4px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.chat-message {
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-name {
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 600;
}

.chat-text {
  margin-top: 4px;
  color: #fff;
  word-break: break-word;
}

.emoji-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.emoji-row button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--chip);
}

.chat-form {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.check-line {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.inline-form input[type="file"] {
  padding: 9px 20px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
}

@media (max-width: 1068px) {
  .content-grid,
  .admin-grid,
  .room-layout {
    grid-template-columns: 1fr;
  }

  .chat-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 833px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-copy {
    min-height: 360px;
    padding: 64px 32px;
  }

  .auth-copy h1 {
    font-size: 40px;
  }

  .auth-copy::after {
    display: none;
  }

  .auth-panel {
    padding: 48px 32px;
  }

  .sub-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .surface {
    padding: 48px 20px;
  }

  .control-strip {
    grid-template-columns: 1fr 1fr;
  }

  .url-input {
    grid-column: 1 / -1;
  }

  .chat-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .nav-inner {
    padding: 0 16px;
  }

  .auth-copy h1 {
    font-size: 34px;
  }

  .auth-copy p {
    font-size: 21px;
  }

  .content-grid,
  .admin-grid,
  .room-layout,
  .file-grid,
  .form-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .wide-card,
  .form-grid .wide {
    grid-column: auto;
  }

  .section-head,
  .list-item,
  .path-row,
  .manager-row,
  .inline-form,
  .chat-form {
    align-items: stretch;
    flex-direction: column;
  }

  .button-cluster {
    justify-content: flex-start;
  }

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

@media (max-width: 419px) {
  .auth-copy {
    min-height: 300px;
    padding: 48px 24px;
  }

  .auth-copy h1 {
    font-size: 28px;
  }

  .auth-panel,
  .utility-card,
  .storage-browser,
  .members-panel,
  .chat-panel {
    padding: 20px;
  }
}
