:root {
  color-scheme: light;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  background: #ffffff;
  color: #1c241f;
}

* {
  box-sizing: border-box;
}

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

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

body.detail-page .page-shell {
  width: min(1580px, calc(100% - 28px));
  padding-top: 14px;
}

.home-header {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 8px auto 28px;
  text-align: center;
}

.home-header[hidden] {
  display: none;
}

.home-logo {
  width: 86px;
  height: 86px;
  object-fit: contain;
}

.home-subtitle {
  max-width: 640px;
  color: #496f58;
  font-size: clamp(1rem, 1.35vw, 1.15rem);
  line-height: 1.45;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 720px;
  font-size: clamp(1.9rem, 2.6vw, 2.4rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
  color: #17241b;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.camera-card {
  display: block;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #dce4db;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgb(24 32 25 / 7%);
  color: inherit;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.camera-card:hover {
  box-shadow: 0 12px 28px rgb(24 32 25 / 12%);
  transform: translateY(-1px);
}

.frame-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1b211d;
}

.camera-frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame-state {
  position: absolute;
  inset: auto 12px 12px 12px;
  padding: 7px 9px;
  border-radius: 6px;
  background: rgb(8 12 10 / 72%);
  color: #fff;
  font-size: 0.84rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #d93025;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.frame-wrap .live-badge,
.detail-frame-wrap .live-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 26%);
}

.camera-frame[src] + .frame-state,
.detail-frame[src] + .frame-state {
  display: none;
}

.camera-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

h2 {
  font-size: 1.03rem;
  line-height: 1.2;
}

.camera-status {
  color: #516157;
  margin-top: 4px;
  min-height: 1.25rem;
  font-size: 0.92rem;
}

.ptz-controls {
  display: grid;
  gap: 12px;
}

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

.zoom-pad {
  display: grid;
  gap: 8px;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-auto-rows: 40px;
  gap: 8px;
}

.detail-view {
  display: block;
}

.detail-view[hidden] {
  display: none;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.detail-topbar[hidden] {
  display: none;
}

.compact-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #244b31;
  font-weight: 700;
  text-decoration: none;
}

.compact-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.back-link {
  color: #244b31;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 25vw, 380px);
  gap: 16px;
  align-items: start;
}

.detail-frame-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #1b211d;
  border-radius: 8px;
}

.detail-frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dce4db;
  border-radius: 8px;
}

.ptz-controls button {
  width: 44px;
  height: 40px;
  border: 1px solid #b7c4b6;
  border-radius: 8px;
  background: #eef4ed;
  color: #162018;
  font-size: 1.18rem;
  font-weight: 700;
  cursor: pointer;
}

.ptz-controls button:hover {
  background: #dfeadd;
}

.ptz-controls button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.direction-pad [data-direction="up"] {
  grid-column: 2;
}

.direction-pad [data-direction="left"] {
  grid-column: 1;
}

.direction-pad [data-direction="right"] {
  grid-column: 3;
}

.direction-pad [data-direction="down"] {
  grid-column: 2;
}

.stop-camera {
  width: auto !important;
  min-width: 132px;
  background: #ffffff !important;
  border-color: #caa9a3 !important;
  color: #743128 !important;
  font-size: 0.95rem !important;
  font-weight: 650 !important;
}

@media (max-width: 920px) {
  .page-shell,
  body.detail-page .page-shell {
    width: min(100% - 16px, 1180px);
    padding: 10px 0 24px;
  }

  .home-header {
    margin: 8px auto 22px;
  }

  .home-logo {
    width: 68px;
    height: 68px;
  }

  h1 {
    font-size: clamp(1.65rem, 7vw, 2rem);
  }

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

  .detail-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .detail-topbar {
    margin-bottom: 8px;
  }

  .compact-logo {
    width: 30px;
    height: 30px;
  }

  .compact-brand span {
    font-size: 0.9rem;
  }

  .back-link {
    font-size: 0.9rem;
  }

  .detail-frame-wrap {
    border-radius: 6px;
  }

  .detail-panel {
    padding: 12px;
  }
}
