/* ========== Base ========== */
:root{
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --panel: #ffffff;
  --panel2:#f9fafb;
  --shadow: 0 10px 30px rgba(0,0,0,.06);
  --radius: 14px;
  --sidebar-w: 280px;
  --topbar-h: 58px;
  
}

*{ box-sizing: border-box; }
html,body{ height:100vh; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ========== Topbar ========== */

}
.topbar{
  position: sticky;
  top:0;
  z-index: 50;
  height: var(--topbar-h);
  display:flex;
  align-items:center;
  gap:12px;
  padding: 0 16px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand{ display:flex; flex-direction:column; line-height:1.1; }
.brand-title{ font-weight: 750; letter-spacing:.2px; }
.brand-sub{ font-size: 12px; color: var(--muted); margin-top: 3px; }

.topbar-right{ margin-left:auto; display:flex; align-items:center; gap:10px; }
.top-link{
  text-decoration:none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
}
.top-link:hover{ background: var(--panel2); }

/* menu toggle: only visible on small screens */
.menu-toggle{
  appearance:none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.menu-toggle:hover{ background: var(--panel2); }

/* ========== Layout ========== */
.layout{
  display:flex;
  min-height: calc(100vh - var(--topbar-h));
}

/* Sidebar */
.sidebar{
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow:auto;
}

.sidebar-inner{
  padding: 14px 12px 20px;
}

.nav-home{
  display:block;
  margin-bottom: 10px;
  font-weight: 650;
  background: var(--panel2);
  border: 1px solid var(--border);
}

.nav-link{
  display:block;
  text-decoration:none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
}
.nav-link:hover{ background: var(--panel2); }

/* Collapsible sections */
.nav-section{
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  margin: 10px 0;
  overflow: hidden;
}

.nav-heading{
  list-style:none;
  cursor: pointer;
  padding: 12px 12px;
  font-weight: 700;
  background: #fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  user-select:none;
}
.nav-heading::-webkit-details-marker{ display:none; }

.nav-heading::after{
  content: "▾";
  color: var(--muted);
  font-size: 14px;
  transform: translateY(-1px);
}
.nav-section:not([open]) .nav-heading::after{
  content: "▸";
}

.nav-children{
  padding: 4px 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--panel2);
}
.nav-children .nav-link{
  margin: 6px 6px 0;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(229,231,235,.9);
}
.nav-children .nav-link:hover{ background: #fff; }

.sidebar-footer{
  margin-top: 14px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

/* Content */
.content{
  flex:1;
  padding: 18px;
  min-width: 0;
}
#spaView {
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;

  /* 捲得到，但不顯示捲軸 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#spaView::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px;
  margin: 0 0 14px 0;
}

.panel h1{ margin: 0 0 8px; font-size: 26px; }
.panel h2{ margin: 0 0 8px; font-size: 18px; }
.panel p{ margin: 0 0 10px; color: #1f2937; }
.panel code{
  background: var(--panel2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 8px;
}

/* ========== Mobile behavior ========== */
/* 預設桌機：側欄常駐；左上角按鈕隱藏 */
@media (min-width: 980px){
  .menu-toggle{ display:none; }
}

/* 小螢幕：側欄抽屜式（用 body.sidebar-open 控制） */
@media (max-width: 979px){
  .sidebar{
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 20px 0 40px rgba(0,0,0,.12);
    z-index: 60;
  }
  body.sidebar-open .sidebar{
    transform: translateX(0);
  }

  /* 右側內容全寬 */
  .content{
    padding: 14px;
    overflow: hidden;
  }

  /* 遮罩 */
  body.sidebar-open::before{
    content:"";
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,.25);
    z-index: 55;
  }
}
