:root {
  color-scheme: dark;
  --bg: #050608;
  --panel: #12161b;
  --panel-2: #191f26;
  --line: #303946;
  --text: #edf2f7;
  --muted: #96a3b5;
  --accent: #33c6a7;
  --danger: #ff6565;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.wall {
  height: 100vh;
  overflow: hidden;
}

.camera-wall {
  display: grid;
  height: 100vh;
  width: 100vw;
  padding: var(--wall-gap, 8px);
  gap: var(--wall-gap, 8px);
  grid-template-columns: repeat(var(--wall-columns, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(120px, 1fr);
  background: radial-gradient(circle at 50% 0, #15191f 0, #050608 42%);
}

.camera-tile {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: #000;
  border: 1px solid #202832;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.camera-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.direct-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.go2rtc-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.camera-nameplate {
  position: absolute;
  top: 8px;
  left: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-wall {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--muted);
}

.settings-link {
  position: fixed;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(8, 10, 13, 0.72);
  text-decoration: none;
  opacity: 0.2;
  transition: opacity 160ms ease, transform 160ms ease;
}

.settings-link:hover,
.settings-link:focus {
  opacity: 1;
  transform: translateY(-1px);
}

.settings {
  min-height: 100vh;
  padding: 24px 24px 90px;
  background: #0a0d11;
}

.settings-header,
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-header {
  margin: 0 auto 22px;
  max-width: 1360px;
}

.settings-header h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.settings-header p,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
}

.settings-header nav {
  display: flex;
  gap: 8px;
}

.settings-grid {
  display: grid;
  max-width: 1360px;
  margin: 0 auto;
  gap: 16px;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.6fr);
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.wide {
  grid-row: span 3;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #080a0d;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
}

.button.primary {
  border-color: #2aa78d;
  background: var(--accent);
  color: #04110e;
  font-weight: 700;
}

.button.subtle {
  background: transparent;
}

.icon-button {
  width: 32px;
  height: 32px;
  font-size: 20px;
}

.camera-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.camera-form {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1015;
}

.camera-form-head,
.split {
  display: flex;
  gap: 10px;
}

.camera-form-head {
  align-items: center;
  justify-content: space-between;
}

.camera-form-head > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.camera-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-order {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.camera-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.split > label {
  flex: 1 1 0;
}

.save-bar {
  position: fixed;
  right: 24px;
  bottom: 18px;
  left: 24px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 27, 0.94);
  box-shadow: var(--shadow);
}

#status {
  color: var(--muted);
}

@media (max-width: 780px) {
  .settings {
    padding: 16px 12px 96px;
  }

  .settings-header,
  .settings-grid,
  .save-bar {
    max-width: none;
  }

  .settings-header,
  .save-bar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

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

  .wide {
    grid-row: auto;
  }
}
