:root {
  --bg: #0f172a;
  --sidebar-bg: #1e293b;
  --sidebar-card: #273549;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --border: #dbe4f0;
  --primary: #2563eb;
  --teal: #0e7c7b;
  --coral: #e36414;
  --gold: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

button { font-family: inherit; }
.hidden { display: none !important; }

.hub-shell {
  display: grid;
  grid-template-columns: 310px 1fr;
  width: 100vw;
  height: 100vh;
  transition: grid-template-columns 0.22s ease;
}

.hub-shell.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.hub-shell.sidebar-collapsed .sidebar {
  border-right: none;
}

.sidebar-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.hub-logo {
  font-size: 1.12rem;
  font-weight: 900;
  color: #fde047;
  margin-bottom: 4px;
}

.hub-desc {
  margin: 0;
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.unit-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.unit-group-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #93c5fd;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  padding-left: 4px;
}

.unit-group-title.u2 {
  color: #6ee7b7;
}

.unit-items {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.nav-item {
  width: 100%;
  border: 2px solid transparent;
  background: var(--sidebar-card);
  color: #f1f5f9;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.nav-item:hover {
  border-color: #60a5fa;
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #93c5fd;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.ni-icon {
  font-size: 1.45rem;
  flex-shrink: 0;
}

.ni-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ni-title {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
}

.ni-meta {
  font-size: 0.74rem;
  color: #cbd5e1;
}

.nav-item.active .ni-meta {
  color: #dbeafe;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.core-note {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(253, 224, 71, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #fef9c3;
}

/* Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #f1f5f9;
  min-width: 0;
}

.control-bar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cb-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.current-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.unit-chip {
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.current-meta h1 {
  margin: 0;
  font-size: 1.04rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-btn {
  border: 1.5px solid var(--border);
  background: #f8fafc;
  color: var(--ink);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 0.83rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.tool-btn:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.tool-btn.primary-tool {
  background: var(--primary);
  color: #fff;
  border-color: #1d4ed8;
}

.tool-btn.primary-tool:hover {
  filter: brightness(1.06);
}

.video-mode-switch {
  display: flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 10px;
  gap: 3px;
}

.vm-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #475569;
  cursor: pointer;
}

.vm-btn.active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Teacher Tip Bar */
.teacher-tip-bar {
  background: #fffbeb;
  border-bottom: 2px solid #fde68a;
  padding: 7px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
  color: #78350f;
}

.tip-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

.tip-badge {
  background: #fde047;
  color: #713f12;
  font-weight: 800;
  font-size: 0.76rem;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.tip-nav {
  display: flex;
  gap: 6px;
}

.mini-nav-btn {
  border: 1.5px solid #fcd34d;
  background: #fff;
  color: #78350f;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.mini-nav-btn:hover:not(:disabled) {
  background: #fef3c7;
}

.mini-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Stage Viewport */
.stage-viewport {
  flex: 1;
  position: relative;
  background: #0f172a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  padding: 12px;
}

.video-stage video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.hub-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.hub-iframe.scaled-1080 {
  width: 1920px;
  height: 1080px;
  flex-shrink: 0;
  transform-origin: center center;
  background: #1a1a1a;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

@media (max-width: 860px) {
  .hub-shell {
    grid-template-columns: 240px 1fr;
  }
}
