:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #eef3f8;
  --text: #17202a;
  --muted: #637083;
  --line: #d9e1ea;
  --primary: #0f6bff;
  --primary-dark: #0a4ec0;
  --danger: #d83232;
  --success: #188754;
  --warning: #b7791f;
  --shadow: 0 18px 45px rgba(25, 42, 70, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.download-link {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 12px 18px;
  text-decoration: none;
  transition: background 0.15s ease, opacity 0.15s ease;
}

button:hover,
.download-link:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary {
  background: #e8eef6;
  color: #1d2b3a;
}

button.secondary:hover {
  background: #dce5f1;
}

button.danger {
  background: var(--danger);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  padding: 12px 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.home-view,
.setup-view {
  display: grid;
  place-items: center;
  padding: 32px;
}

.home-panel,
.setup-card,
.preview-card,
.status-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.home-panel {
  width: min(760px, 100%);
  padding: 42px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
}

h2 {
  font-size: 18px;
}

.intro {
  margin: 16px 0 28px;
  color: var(--muted);
  line-height: 1.7;
}

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

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

.created-room {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.link-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.link-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.link-row code {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(320px, 640px);
  gap: 24px;
  width: min(1180px, 100%);
}

.setup-card {
  padding: 32px;
}

.device-controls {
  display: grid;
  gap: 16px;
}

.preview-card {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  background: #0f1720;
}

video {
  width: 100%;
  height: 100%;
  background: #101820;
  object-fit: cover;
}

.video-caption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  border-radius: 6px;
  background: rgba(10, 18, 28, 0.72);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  padding: 8px 10px;
}

.meter-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 70px;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.meter {
  overflow: hidden;
  height: 10px;
  border-radius: 99px;
  background: #e8eef6;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 0.08s linear;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 22px;
  color: var(--text);
  line-height: 1.6;
}

.consent input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.alert {
  border: 1px solid #f0c36a;
  border-radius: 6px;
  background: #fff8e7;
  color: #6b4b00;
  line-height: 1.6;
  margin: 18px 0;
  padding: 12px 14px;
}

.room-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 22px;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  min-height: 0;
}

.video-stage {
  display: grid;
  grid-template-rows: minmax(320px, 1fr) 210px;
  gap: 18px;
  min-height: calc(100vh - 120px);
}

.video-tile {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #101820;
}

.video-tile.local {
  max-width: 380px;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.status-card {
  box-shadow: none;
  padding: 18px;
}

.recording-status {
  margin-top: 14px;
  color: var(--muted);
  font-weight: 800;
}

.recording-timer {
  margin: 10px 0 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 34px;
  font-weight: 900;
}

.host-controls {
  display: grid;
  gap: 10px;
}

.status-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.status-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  padding-bottom: 8px;
}

.status-list strong {
  color: var(--text);
}

.hint {
  color: var(--muted);
  line-height: 1.6;
}

.badge {
  border-radius: 999px;
  background: #e8eef6;
  color: #1d2b3a;
  font-weight: 900;
  padding: 9px 12px;
}

.badge.good {
  background: #def7ec;
  color: #0f6848;
}

.badge.warn {
  background: #fff0d2;
  color: #80530a;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  box-shadow: var(--shadow);
  line-height: 1.5;
  padding: 14px 16px;
  z-index: 20;
}

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

  .room-view {
    padding: 14px;
  }

  .video-stage {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .home-view,
  .setup-view {
    padding: 16px;
  }

  .home-panel,
  .setup-card {
    padding: 22px;
  }

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

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