:root{
  --header-h: 56px;
  --sidebar-w: 420px;

  --border: #5a5a5a;
  --blue: #4f93c9;
  --gray: #d9d9d9;

  --bg: #ffffff;
  --text: #111;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }

body{
  margin: 0;
  font-family: "Noto Sans JP", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ===== Header ===== */
.app-header{
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.app-header__title{
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

/* SP用ハンバーガー（開くと×になる） */
.hamburger{
  margin-left: auto;
  width: 56px;
  height: 44px;
  border: none;
  background: var(--blue);
  border-radius: 4px;
  display: none; /* PCは非表示 */
  position: relative;
  cursor: pointer;
}
.hamburger span{
  position: absolute;
  left: 14px;
  right: 14px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  transition: transform .15s ease, opacity .15s ease, top .15s ease;
}
.hamburger span:nth-child(1){ top: 14px; }
.hamburger span:nth-child(2){ top: 21px; }
.hamburger span:nth-child(3){ top: 28px; }

/* 開いてる時：× */
body.is-drawer-open .hamburger span:nth-child(1){
  top: 21px;
  transform: rotate(45deg);
}
body.is-drawer-open .hamburger span:nth-child(2){ opacity: 0; }
body.is-drawer-open .hamburger span:nth-child(3){
  top: 21px;
  transform: rotate(-45deg);
}

/* ===== Main Layout ===== */
.app-main{
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}

/* ===== Sidebar (PC: left column) ===== */
.sidebar{
  border-right: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto 1fr auto; /* topbar / scroll / footer */
  min-height: 0;
  background: #fff;
}

.sidebar__topbar{ padding: 0; }
.sidebar__btn{
  width: 100%;
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  padding: 14px 12px;
  cursor: default;
}

.sidebar__list{
  overflow: auto;
  border-top: 1px solid var(--border);
  min-height: 0;
  padding-bottom: 10px;
}

.camera-item{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;

  background: #fff;
  border: none;
  border-bottom: 1px solid #444;
  padding: 16px 14px;
  font-size: 18px;
  text-align: left;
  cursor: pointer;
}
.camera-item:hover{ background: #f5f7fa; }
.camera-item__icon{
  display: inline-flex;
  width: 32px;
  justify-content: center;
  font-weight: 800;
}
.camera-item__name{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__footer{
  border-top: 1px solid var(--border);
  background: var(--gray);
  padding: 14px;
}
.sidebar__footerlink{
  display: block;
  text-align: center;
  padding: 10px 12px;
  color: #111;
  text-decoration: none;
  font-size: 18px;
}
.sidebar__footerlink:hover{ text-decoration: underline; }

/* ===== Map ===== */
.map{ min-width: 0; min-height: 0; }
.map__canvas{ width: 100%; height: 100%; }
.point-label {
  display: table-cell;
	color: #f00;
	background-color: #ff4;
	opacity: 0.8;
	white-space: nowrap;
	font-size: 14px;
	font-weight: bold;
  padding: 2px 4px;
}

.map-legend {
  width: 200px;
  background: rgba(255,255,255,0.95);
  padding: 10px 12px;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  justify-content: space-between;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-icon {
  width: 24px;
  height: 24px;
}

/* ===== Modal (PC-2 / SP-3) ===== */
.modal{
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
}
.modal.is-open{ display: block; }

.modal__overlay{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
}

.modal__dialog{
  position: relative;
  width: min(880px, calc(100vw - 120px));
  margin: 90px auto 0;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  border-radius: 4px;
}

.modal__header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal__title{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
}
.modal__mark{ font-weight: 900; }

.modal__meta{
  font-size: 18px;
  white-space: nowrap;
}
.modal__meta-gap{ display: inline-block; width: 5px; }

.modal__body{ padding: 18px 16px 10px; }
.modal__image{
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #333;
  background: #eee;
  aspect-ratio: auto;
  object-fit: cover;
}

.modal__footer{
  padding: 14px 16px 18px;
  display: flex;
  justify-content: center;
}
.modal__closebtn{
  min-width: 180px;
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  padding: 12px 18px;
  cursor: pointer;
  border-radius: 4px;
}
.modal__closebtn:hover{ filter: brightness(.95); }

/* モーダル開いてるとき背面スクロール抑止 */
body.is-modal-open{ overflow: hidden; }

/* ===== Responsive ===== */
@media (max-width: 900px){
  :root{ --sidebar-w: 320px; }
}

/* SP: map full + list overlay (SP-1/SP-2) */
@media (max-width: 768px){
  .hamburger{ display: inline-block; }

  .app-header__title-inner { display:none; }

  .app-main{
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  /* SPではデフォルト非表示（SP-1） */
  .sidebar{
    display: none;
    border-right: none;
  }

  /* SP-2: 開いてる時はヘッダー下から全面 */
  body.is-drawer-open .sidebar{
    display: grid;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 1950;
    background: #fff;
    grid-template-rows: auto 1fr auto;
    min-height: 0;
  }

  body.is-drawer-open .sidebar__topbar{ padding: 0; }
  body.is-drawer-open .sidebar__btn{
    border-radius: 0;
    padding: 16px 12px;
    font-size: 18px;
  }

  body.is-drawer-open .sidebar__list{
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }

  /* SP-3: モーダルを中央に小さめ */
  .modal__dialog{
    width: calc(100vw - 44px);
    margin: 110px auto 0;
  }
  .modal__header{
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px 16px 12px;
  }
  .modal__title{ font-size: 22px; }
  .modal__meta{ font-size: 18px; }
  .modal__body{ padding: 12px 16px 8px; }
  .modal__footer{ padding: 12px 16px 18px; }
  .modal__closebtn{ min-width: 200px; }
}

@media (max-width: 768px) and (orientation: landscape) {
  
  .modal__dialog{
    width: calc(100vw - 420px);
    margin: 10px auto 0;
  }
  .modal__title{ font-size: 18px; }
  .modal__footer{ padding: 2px; }
  .modal__closebtn{ display: none; }
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
  .modal__dialog{
    width: min(720px, calc(100vw - 120px));
  }
}
