/* ================================================
   css/layout.css — サイドバー・ヘッダー・メイン
   ================================================ */

/* ---- MOBILE HEADER (≤768px のみ表示) ---- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-base);
  border-bottom: 0.5px solid var(--border-light);
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 200;
}
.hamburger {
  width: 36px; height: 36px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px; border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.hamburger span {
  display: block; width: 20px; height: 1.5px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all .2s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.mobile-title { font-size: 14px; font-weight: 500; }

.mobile-action-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  font-size: 18px; color: var(--text-secondary);
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

/* ---- SIDEBAR OVERLAY ---- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
}
.sidebar-overlay.show { display: block; }

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-base);
  border-right: 0.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 300;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease;
}

/* Brand */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 0.5px solid var(--border-light);
  flex-shrink: 0;
}
.brand-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.brand-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.brand-sub  { font-size: 10px; color: var(--text-tertiary); font-family: 'SF Mono', monospace; }

/* Navigation */
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-group-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-tertiary);
  font-family: 'SF Mono', monospace;
  padding: 10px 8px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  margin-bottom: 1px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.nav-item:hover  { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-surface); color: var(--text-primary); font-weight: 500; }

.nav-icon { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.nav-badge:empty { display: none; }

/* Footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 0.5px solid var(--border-light);
  flex-shrink: 0;
}
.conn-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--text-secondary);
  font-family: 'SF Mono', monospace;
  margin-bottom: 5px;
}
.conn-status:last-child { margin-bottom: 0; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
}

.page { display: none; padding: 24px; max-width: 960px; }
.page.active { display: block; }

/* ---- BOTTOM NAV (mobile) ---- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bnav-h);
  background: var(--bg-base);
  border-top: 0.5px solid var(--border-light);
  align-items: stretch;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bnav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none;
  color: var(--text-tertiary);
  font-size: 10px;
  cursor: pointer;
  padding: 6px 0;
  transition: color var(--ease);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bnav-btn.active { color: var(--text-primary); }
.bnav-icon { font-size: 16px; display: block; }
.bnav-label { font-size: 9px; }
.bnav-badge {
  position: absolute;
  top: 6px; right: calc(50% - 14px);
  width: 14px; height: 14px;
  background: var(--red); color: #fff;
  font-size: 8px; font-weight: 700;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
}
.bnav-badge:empty { display: none; }

/* ---- TWO-COL GRID ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
