* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  color: #2c3e50;
  background: #f8f9fa;
  line-height: 1.7;
}

body {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 280px;
  background: #1f2937;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.25s ease;
  z-index: 100;
}

#sidebar header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid #374151;
}

#sidebar h1 {
  font-size: 20px;
  margin-bottom: 4px;
  font-weight: 700;
}

#sidebar .subtitle {
  font-size: 13px;
  color: #9ca3af;
}

#nav {
  flex: 1;
  padding: 12px 0;
}

#nav a {
  display: block;
  padding: 10px 20px;
  color: #d1d5db;
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

#nav a:hover {
  background: #374151;
  color: #fff;
}

#nav a.active {
  background: #374151;
  border-left-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

#nav a.nav-child {
  padding-left: 36px;
  font-size: 13px;
  color: #9ca3af;
}

#nav a.nav-child:hover,
#nav a.nav-child.active {
  color: #fff;
}

#sidebar footer {
  padding: 16px 20px;
  border-top: 1px solid #374151;
  font-size: 12px;
  color: #9ca3af;
}

#sidebar footer code {
  background: #374151;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* Main */
#main {
  flex: 1;
  margin-left: 280px;
  padding: 0;
  min-width: 0;
}

#top-bar {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 50;
}

#menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #374151;
}

#page-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

#notion-link {
  background: #000;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}

#notion-link:hover {
  background: #333;
}

#content {
  padding: 32px 48px 80px;
  max-width: 860px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  color: #9ca3af;
  padding: 80px 0;
}

/* Markdown content */
#content h1 {
  font-size: 28px;
  margin: 8px 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

#content h2 {
  font-size: 22px;
  margin: 32px 0 14px;
  color: #111827;
}

#content h3 {
  font-size: 18px;
  margin: 24px 0 10px;
  color: #374151;
}

#content h4 {
  font-size: 15px;
  margin: 20px 0 8px;
  color: #4b5563;
}

#content p {
  margin: 12px 0;
}

#content ul, #content ol {
  margin: 12px 0;
  padding-left: 28px;
}

#content li {
  margin: 4px 0;
}

#content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.9em;
  color: #be185d;
}

#content pre {
  background: #1f2937;
  color: #f3f4f6;
  padding: 16px 18px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 14px 0;
  font-size: 13.5px;
  line-height: 1.6;
}

#content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

#content blockquote {
  border-left: 4px solid #3b82f6;
  background: #eff6ff;
  padding: 12px 18px;
  margin: 14px 0;
  color: #1e40af;
  border-radius: 0 6px 6px 0;
}

#content blockquote p { margin: 6px 0; }

#content table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 14px;
}

#content th, #content td {
  border: 1px solid #e5e7eb;
  padding: 10px 14px;
  text-align: left;
}

#content th {
  background: #f9fafb;
  font-weight: 600;
}

#content tr:nth-child(even) td {
  background: #fafafa;
}

#content a {
  color: #2563eb;
  text-decoration: none;
  border-bottom: 1px solid #93c5fd;
}

#content a:hover {
  color: #1e40af;
  border-bottom-color: #1e40af;
}

#content hr {
  border: none;
  height: 1px;
  background: #e5e7eb;
  margin: 28px 0;
}

#content strong { color: #111827; }

/* ============================================================
   Interactive: Departments page
   ============================================================ */
.page-intro {
  background: #eff6ff;
  border-left: 4px solid #3b82f6;
  padding: 12px 16px;
  color: #1e40af;
  border-radius: 0 6px 6px 0;
  margin-bottom: 20px;
}

.dept-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin: 18px 0;
  padding: 18px 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.dept-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f3f4f6;
}

.dept-name {
  font-size: 20px;
  color: #111827;
  margin: 0;
}

.dept-progress {
  font-size: 13px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.dept-section {
  margin: 16px 0;
}

.section-title {
  font-size: 14px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 8px;
  font-weight: 600;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  margin: 0;
}

.task-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #3b82f6;
  flex-shrink: 0;
}

.task-text {
  flex: 1;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: text;
  font-size: 15px;
  color: #374151;
}

.task-done {
  text-decoration: line-through;
  color: #9ca3af;
}

.qa-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qa-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
}

.qa-q, .qa-a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
}

.qa-a {
  border-top: 1px dashed #e5e7eb;
  margin-top: 6px;
  padding-top: 8px;
}

.qa-label {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.qa-label-a {
  background: #10b981;
}

.qa-q-text {
  flex: 1;
  font-weight: 600;
  color: #111827;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: text;
}

.qa-a-text {
  flex: 1;
  color: #374151;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: text;
  min-height: 1.5em;
  white-space: pre-wrap;
}

/* Empty answer placeholder */
.qa-a-text:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-style: italic;
}

/* Editable hover/focus */
.editable {
  transition: background 0.15s, box-shadow 0.15s;
}

.editable:hover {
  background: #e0f2fe;
}

.editable:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Buttons */
.btn-del {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
  padding: 0 6px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.task-item:hover .btn-del,
.qa-q:hover .btn-del {
  opacity: 1;
}

.btn-del:hover {
  color: #b91c1c;
}

.btn-add {
  background: none;
  border: 1px dashed #cbd5e1;
  color: #6b7280;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 8px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-add:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}

.reset-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding: 14px 18px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.btn-reset {
  background: #fff;
  border: 1px solid #d1d5db;
  color: #ef4444;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.btn-reset:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.save-hint {
  font-size: 12px;
  color: #9ca3af;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  }

  #main {
    margin-left: 0;
  }

  #menu-toggle {
    display: block;
  }

  #content {
    padding: 24px 20px 60px;
  }

  #top-bar {
    padding: 12px 16px;
  }

  #page-title {
    font-size: 15px;
  }
}
